|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Gearman Bundle for Symfony2 |
|
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 Mmoreram\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
|
|
|
|
|
20
|
|
|
use Mmoreram\GearmanBundle\Command\Abstracts\AbstractGearmanCommand; |
|
21
|
|
|
use Mmoreram\GearmanBundle\Service\GearmanClient; |
|
22
|
|
|
use Mmoreram\GearmanBundle\Service\GearmanDescriber; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Gearman Job Describe Command class |
|
26
|
|
|
* |
|
27
|
|
|
* @since 2.3.1 |
|
28
|
|
|
*/ |
|
29
|
|
|
class GearmanJobDescribeCommand extends AbstractGearmanCommand |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @var GearmanClient |
|
33
|
|
|
* |
|
34
|
|
|
* Gearman client |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $gearmanClient; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var GearmanDescriber |
|
40
|
|
|
* |
|
41
|
|
|
* GearmanDescriber |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $gearmanDescriber; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Set gearman client |
|
47
|
|
|
* |
|
48
|
|
|
* @param GearmanClient $gearmanClient Gearman client |
|
49
|
|
|
* |
|
50
|
|
|
* @return GearmanJobDescribeCommand self Object |
|
51
|
|
|
*/ |
|
52
|
1 |
|
public function setGearmanClient(GearmanClient $gearmanClient) |
|
53
|
|
|
{ |
|
54
|
1 |
|
$this->gearmanClient = $gearmanClient; |
|
55
|
|
|
|
|
56
|
1 |
|
return $this; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* set Gearman describer |
|
61
|
|
|
* |
|
62
|
|
|
* @param GearmanDescriber $gearmanDescriber GearmanDescriber |
|
63
|
|
|
* |
|
64
|
|
|
* @return GearmanJobDescribeCommand self Object |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function setGearmanDescriber(GearmanDescriber $gearmanDescriber) |
|
67
|
|
|
{ |
|
68
|
1 |
|
$this->gearmanDescriber = $gearmanDescriber; |
|
69
|
|
|
|
|
70
|
1 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Console Command configuration |
|
75
|
|
|
*/ |
|
76
|
1 |
|
protected function configure() |
|
77
|
|
|
{ |
|
78
|
|
|
$this |
|
79
|
1 |
|
->setName('gearman:job:describe') |
|
80
|
1 |
|
->setDescription('Describe given job') |
|
81
|
1 |
|
->addArgument( |
|
82
|
1 |
|
'job', |
|
83
|
1 |
|
InputArgument::REQUIRED, |
|
84
|
1 |
|
'job to describe' |
|
85
|
|
|
); |
|
86
|
1 |
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Executes the current command. |
|
90
|
|
|
* |
|
91
|
|
|
* @param InputInterface $input An InputInterface instance |
|
92
|
|
|
* @param OutputInterface $output An OutputInterface instance |
|
93
|
|
|
* |
|
94
|
|
|
* @return integer 0 if everything went fine, or an error code |
|
95
|
|
|
* |
|
96
|
|
|
* @throws \LogicException When this abstract class is not implemented |
|
97
|
|
|
*/ |
|
98
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
99
|
|
|
{ |
|
100
|
1 |
|
$job = $input->getArgument('job'); |
|
101
|
1 |
|
$job = $this->gearmanClient->getJob($job); |
|
102
|
|
|
|
|
103
|
|
|
$this |
|
104
|
1 |
|
->gearmanDescriber |
|
105
|
1 |
|
->describeJob($output, $job); |
|
106
|
1 |
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|