1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LimeSoda\Aoe\Scheduler\Job; |
4
|
|
|
|
5
|
|
|
use N98\Magento\Command\AbstractMagentoCommand; |
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
|
10
|
|
|
class Status extends AbstractMagentoCommand |
11
|
|
|
{ |
12
|
|
|
protected function configure() |
13
|
|
|
{ |
14
|
|
|
$this |
15
|
|
|
->setName('ls:aoe:scheduler:job:status') |
16
|
|
|
->addArgument('code', InputArgument::REQUIRED, 'Job code') |
17
|
|
|
->addArgument('status', InputArgument::REQUIRED, 'Job status') |
18
|
|
|
->setDescription('Sets the job status') |
19
|
|
|
->setHelp( |
20
|
|
|
<<<EOT |
21
|
|
|
Sets the status of a job as used by Aoe_Scheduler >= 1.0.0. |
22
|
|
|
EOT |
23
|
|
|
); |
24
|
|
|
|
25
|
|
|
; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
30
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
31
|
|
|
* @return int|void |
32
|
|
|
*/ |
33
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
34
|
|
|
{ |
35
|
|
|
$this->detectMagento($output); |
36
|
|
|
if ($this->initMagento()) { |
37
|
|
|
$name = strip_tags($input->getArgument('code')); |
38
|
|
|
$status = intval(strip_tags($input->getArgument('status'))); |
39
|
|
|
|
40
|
|
|
if ($status !== 0 && $status !== 1) { |
41
|
|
|
throw new \Exception("Status has to be 0 or 1."); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$key = 'crontab/jobs/' . $name . '/is_active'; |
45
|
|
|
\Mage::app()->getConfig()->saveConfig($key, $status); |
46
|
|
|
$output->writeln("Job '" . $name . "': set status to '" . $status . "'."); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|