1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Gearman Bundle for Symfony2 / Symfony3 |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* Feel free to edit as you please, and have fun. |
10
|
|
|
* |
11
|
|
|
* @author Marc Morera <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Mkk\GearmanBundle\Command; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
use Mkk\GearmanBundle\Command\Abstracts\AbstractGearmanCommand; |
20
|
|
|
use Mkk\GearmanBundle\Service\GearmanClient; |
21
|
|
|
use Mkk\GearmanBundle\Service\GearmanDescriber; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Gearman Job Describe Command class |
25
|
|
|
*/ |
26
|
|
|
class GearmanJobDescribeCommand extends AbstractGearmanCommand |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var GearmanClient |
30
|
|
|
* |
31
|
|
|
* Gearman client |
32
|
|
|
*/ |
33
|
|
|
protected $gearmanClient; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var GearmanDescriber |
37
|
|
|
* |
38
|
|
|
* GearmanDescriber |
39
|
|
|
*/ |
40
|
|
|
protected $gearmanDescriber; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Set gearman client |
44
|
|
|
* |
45
|
|
|
* @param GearmanClient $gearmanClient Gearman client |
46
|
|
|
* |
47
|
|
|
* @return GearmanJobDescribeCommand self Object |
48
|
|
|
*/ |
49
|
1 |
|
public function setGearmanClient(GearmanClient $gearmanClient) |
50
|
|
|
{ |
51
|
1 |
|
$this->gearmanClient = $gearmanClient; |
52
|
|
|
|
53
|
1 |
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* set Gearman describer |
58
|
|
|
* |
59
|
|
|
* @param GearmanDescriber $gearmanDescriber GearmanDescriber |
60
|
|
|
* |
61
|
|
|
* @return GearmanJobDescribeCommand self Object |
62
|
|
|
*/ |
63
|
1 |
|
public function setGearmanDescriber(GearmanDescriber $gearmanDescriber) |
64
|
|
|
{ |
65
|
1 |
|
$this->gearmanDescriber = $gearmanDescriber; |
66
|
|
|
|
67
|
1 |
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Console Command configuration |
72
|
|
|
*/ |
73
|
1 |
|
protected function configure() |
74
|
|
|
{ |
75
|
|
|
$this |
76
|
1 |
|
->setName('gearman:job:describe') |
77
|
1 |
|
->setDescription('Describe given job') |
78
|
1 |
|
->addArgument( |
79
|
1 |
|
'job', |
80
|
1 |
|
InputArgument::REQUIRED, |
81
|
1 |
|
'job to describe' |
82
|
|
|
); |
83
|
1 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Executes the current command. |
87
|
|
|
* |
88
|
|
|
* @param InputInterface $input An InputInterface instance |
89
|
|
|
* @param OutputInterface $output An OutputInterface instance |
90
|
|
|
* |
91
|
|
|
* @return integer 0 if everything went fine, or an error code |
|
|
|
|
92
|
|
|
* |
93
|
|
|
* @throws \LogicException When this abstract class is not implemented |
94
|
|
|
*/ |
95
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
96
|
|
|
{ |
97
|
1 |
|
$job = $input->getArgument('job'); |
98
|
1 |
|
$job = $this->gearmanClient->getJob($job); |
99
|
|
|
|
100
|
|
|
$this |
101
|
1 |
|
->gearmanDescriber |
102
|
1 |
|
->describeJob($output, $job); |
103
|
1 |
|
} |
104
|
|
|
} |
|
|
|
|
105
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.