Skip to content

Commit 1312622

Browse files
authored
Updated GearmanDescriber to detect path for bin/console over app/console (#196)
1 parent c94dbc6 commit 1312622

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

Service/GearmanDescriber.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ class GearmanDescriber
3030
*/
3131
private $kernel;
3232

33-
/**
34-
* Root kernel directory
35-
*
36-
* @var string
37-
*/
38-
private $rootDir;
3933

4034
/**
4135
* Construct method
@@ -45,14 +39,6 @@ class GearmanDescriber
4539
public function __construct(KernelInterface $kernel)
4640
{
4741
$this->kernel = $kernel;
48-
49-
// Symfony 3.3+ compatibility, get kernel root dir
50-
if(method_exists($this->kernel, 'getProjectDir')){
51-
$r = new \ReflectionObject($this->kernel);
52-
$this->rootDir = \dirname($r->getFileName());
53-
} else {
54-
$this->rootDir = $this->kernel->getRootDir();
55-
}
5642
}
5743

5844
/**
@@ -68,7 +54,7 @@ public function describeJob(OutputInterface $output, array $worker)
6854
/**
6955
* Commandline
7056
*/
71-
$script = $this->rootDir . '/console gearman:job:execute';
57+
$script = $this->getConsolePath() . 'gearman:job:execute';
7258

7359
/**
7460
* A job descriptions contains its worker description
@@ -124,7 +110,7 @@ public function describeWorker(OutputInterface $output, array $worker, $tinyJobD
124110
/**
125111
* Commandline
126112
*/
127-
$script = $this->rootDir . '/console gearman:worker:execute';
113+
$script = $this->getConsolePath() . ' gearman:worker:execute';
128114

129115
$output->writeln('');
130116
$output->writeln('<info>@Worker\className : ' . $worker['className'] . '</info>');
@@ -182,4 +168,21 @@ public function describeWorker(OutputInterface $output, array $worker, $tinyJobD
182168
$output->writeln('<comment> ' . $worker['description'] . '</comment>');
183169
$output->writeln('');
184170
}
171+
172+
private function getConsolePath()
173+
{
174+
// Symfony 3.3+ compatibility, get kernel root dir
175+
if(method_exists($this->kernel, 'getProjectDir') && false){
176+
$projectDir = $this->kernel->getProjectDir();
177+
} else {
178+
$projectDir = $this->kernel->getRootDir().'/..';
179+
}
180+
181+
if(true === file_exists($projectDir.'/bin/console')){
182+
return realpath($projectDir. '/bin/console');
183+
} else {
184+
return realpath($projectDir. '/app/console');
185+
}
186+
187+
}
185188
}

0 commit comments

Comments
 (0)