@@ -136,6 +136,9 @@ |
||
136 | 136 | $job->setNextRun($newTime); |
137 | 137 | } |
138 | 138 | |
139 | + /** |
|
140 | + * @param string $output |
|
141 | + */ |
|
139 | 142 | protected function recordJobResult(EntityManager $em, CronJob $job, $timeTaken, $output, $resultCode) |
140 | 143 | { |
141 | 144 | // Create a new CronJobResult |
@@ -1,19 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Alpixel\Bundle\CronBundle\Command; |
3 | 3 | use Doctrine\ORM\EntityManager; |
4 | - |
|
5 | 4 | use Symfony\Component\Console\Input\ArgvInput; |
6 | - |
|
7 | 5 | use Alpixel\Bundle\CronBundle\Entity\CronJobResult; |
8 | - |
|
9 | 6 | use Alpixel\Bundle\CronBundle\Entity\CronJob; |
10 | - |
|
11 | 7 | use Symfony\Component\Console\Output\OutputInterface; |
12 | - |
|
13 | 8 | use Symfony\Component\Console\Input\InputInterface; |
14 | - |
|
15 | 9 | use Symfony\Component\Console\Input\InputArgument; |
16 | - |
|
17 | 10 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
18 | 11 | |
19 | 12 | class CronRunCommand extends ContainerAwareCommand |
@@ -21,8 +21,8 @@ |
||
21 | 21 | protected function configure() |
22 | 22 | { |
23 | 23 | $this->setName("cron:run") |
24 | - ->setDescription("Runs any currently schedule cron jobs") |
|
25 | - ->addArgument("job", InputArgument::OPTIONAL, "Run only this job (if enabled)"); |
|
24 | + ->setDescription("Runs any currently schedule cron jobs") |
|
25 | + ->addArgument("job", InputArgument::OPTIONAL, "Run only this job (if enabled)"); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | $jobRepo = $em->getRepository('CronBundle:CronJob'); |
33 | 33 | |
34 | 34 | $jobsToRun = array(); |
35 | - if($jobName = $input->getArgument('job')) |
|
35 | + if ($jobName = $input->getArgument('job')) |
|
36 | 36 | { |
37 | 37 | try |
38 | 38 | { |
39 | 39 | $jobObj = $jobRepo->findOneByCommand($jobName); |
40 | - if($jobObj->getEnabled()) |
|
40 | + if ($jobObj->getEnabled()) |
|
41 | 41 | { |
42 | 42 | $jobsToRun = array($jobObj); |
43 | 43 | } |
44 | 44 | } |
45 | - catch(\Exception $e) |
|
45 | + catch (\Exception $e) |
|
46 | 46 | { |
47 | 47 | $output->writeln("Couldn't find a job by the name of $jobName"); |
48 | 48 | return CronJobResult::FAILED; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $jobCount = count($jobsToRun); |
57 | 57 | $output->writeln("Running $jobCount jobs:"); |
58 | 58 | |
59 | - foreach($jobsToRun as $job) |
|
59 | + foreach ($jobsToRun as $job) |
|
60 | 60 | { |
61 | 61 | $this->runJob($job, $output, $em); |
62 | 62 | } |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | |
72 | 72 | protected function runJob(CronJob $job, OutputInterface $output, EntityManager $em) |
73 | 73 | { |
74 | - $output->write("Running " . $job->getCommand() . ": "); |
|
74 | + $output->write("Running ".$job->getCommand().": "); |
|
75 | 75 | |
76 | 76 | try |
77 | 77 | { |
78 | 78 | $commandToRun = $this->getApplication()->get($job->getCommand()); |
79 | 79 | } |
80 | - catch(InvalidArgumentException $ex) |
|
80 | + catch (InvalidArgumentException $ex) |
|
81 | 81 | { |
82 | 82 | $output->writeln(" skipped (command no longer exists)"); |
83 | 83 | $this->recordJobResult($em, $job, 0, "Command no longer exists", CronJobResult::SKIPPED); |
@@ -94,32 +94,32 @@ discard block |
||
94 | 94 | { |
95 | 95 | $returnCode = $commandToRun->execute($emptyInput, $jobOutput); |
96 | 96 | } |
97 | - catch(\Exception $ex) |
|
97 | + catch (\Exception $ex) |
|
98 | 98 | { |
99 | 99 | $returnCode = CronJobResult::FAILED; |
100 | 100 | $jobOutput->writeln(""); |
101 | - $jobOutput->writeln("Job execution failed with exception " . get_class($ex) . ":"); |
|
101 | + $jobOutput->writeln("Job execution failed with exception ".get_class($ex).":"); |
|
102 | 102 | $jobOutput->writeln($ex->__toString()); |
103 | 103 | } |
104 | 104 | $jobEnd = microtime(true); |
105 | 105 | |
106 | 106 | // Clamp the result to accepted values |
107 | - if($returnCode < CronJobResult::RESULT_MIN || $returnCode > CronJobResult::RESULT_MAX) |
|
107 | + if ($returnCode < CronJobResult::RESULT_MIN || $returnCode > CronJobResult::RESULT_MAX) |
|
108 | 108 | { |
109 | 109 | $returnCode = CronJobResult::FAILED; |
110 | 110 | } |
111 | 111 | |
112 | 112 | // Output the result |
113 | 113 | $statusStr = "unknown"; |
114 | - if($returnCode == CronJobResult::SKIPPED) |
|
114 | + if ($returnCode == CronJobResult::SKIPPED) |
|
115 | 115 | { |
116 | 116 | $statusStr = "skipped"; |
117 | 117 | } |
118 | - elseif($returnCode == CronJobResult::SUCCEEDED) |
|
118 | + elseif ($returnCode == CronJobResult::SUCCEEDED) |
|
119 | 119 | { |
120 | 120 | $statusStr = "succeeded"; |
121 | 121 | } |
122 | - elseif($returnCode == CronJobResult::FAILED) |
|
122 | + elseif ($returnCode == CronJobResult::FAILED) |
|
123 | 123 | { |
124 | 124 | $statusStr = "failed"; |
125 | 125 | } |
@@ -41,14 +41,12 @@ discard block |
||
41 | 41 | { |
42 | 42 | $jobsToRun = array($jobObj); |
43 | 43 | } |
44 | - } |
|
45 | - catch(\Exception $e) |
|
44 | + } catch(\Exception $e) |
|
46 | 45 | { |
47 | 46 | $output->writeln("Couldn't find a job by the name of $jobName"); |
48 | 47 | return CronJobResult::FAILED; |
49 | 48 | } |
50 | - } |
|
51 | - else |
|
49 | + } else |
|
52 | 50 | { |
53 | 51 | $jobsToRun = $jobRepo->findDueTasks(); |
54 | 52 | } |
@@ -76,8 +74,7 @@ discard block |
||
76 | 74 | try |
77 | 75 | { |
78 | 76 | $commandToRun = $this->getApplication()->get($job->getCommand()); |
79 | - } |
|
80 | - catch(InvalidArgumentException $ex) |
|
77 | + } catch(InvalidArgumentException $ex) |
|
81 | 78 | { |
82 | 79 | $output->writeln(" skipped (command no longer exists)"); |
83 | 80 | $this->recordJobResult($em, $job, 0, "Command no longer exists", CronJobResult::SKIPPED); |
@@ -93,8 +90,7 @@ discard block |
||
93 | 90 | try |
94 | 91 | { |
95 | 92 | $returnCode = $commandToRun->execute($emptyInput, $jobOutput); |
96 | - } |
|
97 | - catch(\Exception $ex) |
|
93 | + } catch(\Exception $ex) |
|
98 | 94 | { |
99 | 95 | $returnCode = CronJobResult::FAILED; |
100 | 96 | $jobOutput->writeln(""); |
@@ -114,12 +110,10 @@ discard block |
||
114 | 110 | if($returnCode == CronJobResult::SKIPPED) |
115 | 111 | { |
116 | 112 | $statusStr = "skipped"; |
117 | - } |
|
118 | - elseif($returnCode == CronJobResult::SUCCEEDED) |
|
113 | + } elseif($returnCode == CronJobResult::SUCCEEDED) |
|
119 | 114 | { |
120 | 115 | $statusStr = "succeeded"; |
121 | - } |
|
122 | - elseif($returnCode == CronJobResult::FAILED) |
|
116 | + } elseif($returnCode == CronJobResult::FAILED) |
|
123 | 117 | { |
124 | 118 | $statusStr = "failed"; |
125 | 119 | } |
@@ -1,21 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Alpixel\Bundle\CronBundle\Command; |
3 | 3 | use Alpixel\Bundle\CronBundle\Entity\CronJob; |
4 | - |
|
5 | 4 | use Doctrine\ORM\EntityManager; |
6 | - |
|
7 | 5 | use Symfony\Component\Console\Command\Command; |
8 | - |
|
9 | 6 | use Alpixel\Bundle\CronBundle\Annotation\CronJob as CronJobAnno; |
10 | - |
|
11 | -use Symfony\Bundle\DoctrineBundle\Registry; |
|
12 | - |
|
13 | 7 | use Symfony\Component\Console\Output\OutputInterface; |
14 | - |
|
15 | 8 | use Symfony\Component\Console\Input\InputInterface; |
16 | - |
|
17 | 9 | use Symfony\Component\Console\Input\InputOption; |
18 | - |
|
19 | 10 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
20 | 11 | |
21 | 12 | class CronScanCommand extends ContainerAwareCommand |
@@ -23,9 +23,9 @@ |
||
23 | 23 | protected function configure() |
24 | 24 | { |
25 | 25 | $this->setName("cron:scan") |
26 | - ->setDescription("Scans for any new or deleted cron jobs") |
|
27 | - ->addOption('keep-deleted', 'k', InputOption::VALUE_NONE, 'If set, deleted cron jobs will not be removed') |
|
28 | - ->addOption('default-disabled', 'd', InputOption::VALUE_NONE, 'If set, new jobs will be disabled by default'); |
|
26 | + ->setDescription("Scans for any new or deleted cron jobs") |
|
27 | + ->addOption('keep-deleted', 'k', InputOption::VALUE_NONE, 'If set, deleted cron jobs will not be removed') |
|
28 | + ->addOption('default-disabled', 'd', InputOption::VALUE_NONE, 'If set, new jobs will be disabled by default'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -42,16 +42,16 @@ discard block |
||
42 | 42 | // Enumerate all the jobs currently loaded |
43 | 43 | $reader = $this->getContainer()->get("annotation_reader"); |
44 | 44 | |
45 | - foreach($this->getApplication()->all() as $command) |
|
45 | + foreach ($this->getApplication()->all() as $command) |
|
46 | 46 | { |
47 | 47 | // Check for an @CronJob annotation |
48 | 48 | $reflClass = new \ReflectionClass($command); |
49 | - foreach($reader->getClassAnnotations($reflClass) as $anno) |
|
49 | + foreach ($reader->getClassAnnotations($reflClass) as $anno) |
|
50 | 50 | { |
51 | - if($anno instanceof CronJobAnno) |
|
51 | + if ($anno instanceof CronJobAnno) |
|
52 | 52 | { |
53 | 53 | $job = $command->getName(); |
54 | - if(array_key_exists($job, $knownJobs)) |
|
54 | + if (array_key_exists($job, $knownJobs)) |
|
55 | 55 | { |
56 | 56 | // Clear it from the known jobs so that we don't try to delete it |
57 | 57 | unset($knownJobs[$job]); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // Update the job if necessary |
60 | 60 | $currentJob = $jobRepo->findOneByCommand($job); |
61 | 61 | $currentJob->setDescription($command->getDescription()); |
62 | - if($currentJob->getInterval() != $anno->value) |
|
62 | + if ($currentJob->getInterval() != $anno->value) |
|
63 | 63 | { |
64 | 64 | $newTime = new \DateTime(); |
65 | 65 | $newTime = $newTime->add(new \DateInterval($anno->value)); |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | // Clear any jobs that weren't found |
81 | - if(!$keepDeleted) |
|
81 | + if (!$keepDeleted) |
|
82 | 82 | { |
83 | - foreach(array_keys($knownJobs) as $deletedJob) |
|
83 | + foreach (array_keys($knownJobs) as $deletedJob) |
|
84 | 84 | { |
85 | 85 | $output->writeln("Deleting job: $deletedJob"); |
86 | 86 | $jobToDelete = $jobRepo->findOneByCommand($deletedJob); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $newJob->setNextRun(new \DateTime()); |
102 | 102 | $newJob->setEnabled(!$defaultDisabled); |
103 | 103 | |
104 | - $output->writeln("Added the job " . $newJob->getCommand() . " with interval " . $newJob->getInterval()); |
|
104 | + $output->writeln("Added the job ".$newJob->getCommand()." with interval ".$newJob->getInterval()); |
|
105 | 105 | $em->persist($newJob); |
106 | 106 | } |
107 | 107 | } |
@@ -68,8 +68,7 @@ |
||
68 | 68 | $currentJob->setNextRun($newTime); |
69 | 69 | $output->writeln("Updated interval for $job to {$anno->value}"); |
70 | 70 | } |
71 | - } |
|
72 | - else |
|
71 | + } else |
|
73 | 72 | { |
74 | 73 | $this->newJobFound($em, $output, $command, $anno, $defaultDisabled); |
75 | 74 | } |
@@ -1,15 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Alpixel\Bundle\CronBundle\Command; |
3 | 3 | use Alpixel\Bundle\CronBundle\Entity\CronJobResult; |
4 | - |
|
5 | 4 | use Alpixel\Bundle\CronBundle\Entity\CronJob; |
6 | - |
|
7 | 5 | use Symfony\Component\Console\Output\OutputInterface; |
8 | - |
|
9 | 6 | use Symfony\Component\Console\Input\InputInterface; |
10 | - |
|
11 | 7 | use Symfony\Component\Console\Input\InputArgument; |
12 | - |
|
13 | 8 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
14 | 9 | |
15 | 10 | class CronStatusCommand extends ContainerAwareCommand |
@@ -17,8 +17,8 @@ |
||
17 | 17 | protected function configure() |
18 | 18 | { |
19 | 19 | $this->setName("cron:status") |
20 | - ->setDescription("Displays the current status of cron jobs") |
|
21 | - ->addArgument("job", InputArgument::OPTIONAL, "Show information for only this job"); |
|
20 | + ->setDescription("Displays the current status of cron jobs") |
|
21 | + ->addArgument("job", InputArgument::OPTIONAL, "Show information for only this job"); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | $output->writeln("Cron job statuses:"); |
28 | 28 | |
29 | 29 | $cronJobs = array(); |
30 | - if($jobName = $input->getArgument('job')) |
|
30 | + if ($jobName = $input->getArgument('job')) |
|
31 | 31 | { |
32 | 32 | try |
33 | 33 | { |
34 | 34 | $cronJobs = array($jobRepo->findOneByCommand($jobName)); |
35 | 35 | } |
36 | - catch(\Exception $e) |
|
36 | + catch (\Exception $e) |
|
37 | 37 | { |
38 | 38 | $output->writeln("Couldn't find a job by the name of $jobName"); |
39 | 39 | return CronJobResult::FAILED; |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | $cronJobs = $em->getRepository('CronBundle:CronJob')->findAll(); |
45 | 45 | } |
46 | 46 | |
47 | - foreach($cronJobs as $cronJob) |
|
47 | + foreach ($cronJobs as $cronJob) |
|
48 | 48 | { |
49 | - $output->write(" - " . $cronJob->getCommand()); |
|
50 | - if(!$cronJob->getEnabled()) |
|
49 | + $output->write(" - ".$cronJob->getCommand()); |
|
50 | + if (!$cronJob->getEnabled()) |
|
51 | 51 | { |
52 | 52 | $output->write(" (disabled)"); |
53 | 53 | } |
54 | 54 | $output->writeln(""); |
55 | - $output->writeln(" Description: " . $cronJob->getDescription()); |
|
56 | - if(!$cronJob->getEnabled()) |
|
55 | + $output->writeln(" Description: ".$cronJob->getDescription()); |
|
56 | + if (!$cronJob->getEnabled()) |
|
57 | 57 | { |
58 | 58 | $output->writeln(" Not scheduled"); |
59 | 59 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $output->write(" Scheduled for: "); |
63 | 63 | $now = new \DateTime(); |
64 | - if($cronJob->getNextRun() <= $now) |
|
64 | + if ($cronJob->getNextRun() <= $now) |
|
65 | 65 | { |
66 | 66 | $output->writeln("Next run"); |
67 | 67 | } |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | $output->writeln(strftime("%c", $cronJob->getNextRun()->getTimestamp())); |
71 | 71 | } |
72 | 72 | } |
73 | - if($cronJob->getMostRecentRun()) |
|
73 | + if ($cronJob->getMostRecentRun()) |
|
74 | 74 | { |
75 | 75 | $status = "Unknown"; |
76 | - switch($cronJob->getMostRecentRun()->getResult()) |
|
76 | + switch ($cronJob->getMostRecentRun()->getResult()) |
|
77 | 77 | { |
78 | 78 | case CronJobResult::SUCCEEDED: |
79 | 79 | $status = "Successful"; |
@@ -32,14 +32,12 @@ discard block |
||
32 | 32 | try |
33 | 33 | { |
34 | 34 | $cronJobs = array($jobRepo->findOneByCommand($jobName)); |
35 | - } |
|
36 | - catch(\Exception $e) |
|
35 | + } catch(\Exception $e) |
|
37 | 36 | { |
38 | 37 | $output->writeln("Couldn't find a job by the name of $jobName"); |
39 | 38 | return CronJobResult::FAILED; |
40 | 39 | } |
41 | - } |
|
42 | - else |
|
40 | + } else |
|
43 | 41 | { |
44 | 42 | $cronJobs = $em->getRepository('CronBundle:CronJob')->findAll(); |
45 | 43 | } |
@@ -56,16 +54,14 @@ discard block |
||
56 | 54 | if(!$cronJob->getEnabled()) |
57 | 55 | { |
58 | 56 | $output->writeln(" Not scheduled"); |
59 | - } |
|
60 | - else |
|
57 | + } else |
|
61 | 58 | { |
62 | 59 | $output->write(" Scheduled for: "); |
63 | 60 | $now = new \DateTime(); |
64 | 61 | if($cronJob->getNextRun() <= $now) |
65 | 62 | { |
66 | 63 | $output->writeln("Next run"); |
67 | - } |
|
68 | - else |
|
64 | + } else |
|
69 | 65 | { |
70 | 66 | $output->writeln(strftime("%c", $cronJob->getNextRun()->getTimestamp())); |
71 | 67 | } |
@@ -86,8 +82,7 @@ discard block |
||
86 | 82 | break; |
87 | 83 | } |
88 | 84 | $output->writeln(" Last run was: $status"); |
89 | - } |
|
90 | - else |
|
85 | + } else |
|
91 | 86 | { |
92 | 87 | $output->writeln(" This job has not yet been run"); |
93 | 88 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * Set nextRun |
138 | 138 | * |
139 | - * @param datetime $nextRun |
|
139 | + * @param \DateTime $nextRun |
|
140 | 140 | */ |
141 | 141 | public function setNextRun($nextRun) |
142 | 142 | { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * Add results |
158 | 158 | * |
159 | - * @param Alpixel\Bundle\CronBundle\Entity\CronJobResult $results |
|
159 | + * @param CronJobResult $results |
|
160 | 160 | */ |
161 | 161 | public function addCronJobResult(\Alpixel\Bundle\CronBundle\Entity\CronJobResult $results) |
162 | 162 | { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * Set mostRecentRun |
178 | 178 | * |
179 | - * @param Alpixel\Bundle\CronBundle\Entity\CronJobResult $mostRecentRun |
|
179 | + * @param CronJobResult $mostRecentRun |
|
180 | 180 | */ |
181 | 181 | public function setMostRecentRun(\Alpixel\Bundle\CronBundle\Entity\CronJobResult $mostRecentRun) |
182 | 182 | { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | /** |
187 | 187 | * Get mostRecentRun |
188 | 188 | * |
189 | - * @return Alpixel\Bundle\CronBundle\Entity\CronJobResult |
|
189 | + * @return CronJobResult |
|
190 | 190 | */ |
191 | 191 | public function getMostRecentRun() |
192 | 192 | { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * Set job |
152 | 152 | * |
153 | - * @param Alpixel\Bundle\CronBundle\Entity\CronJob $job |
|
153 | + * @param CronJob $job |
|
154 | 154 | */ |
155 | 155 | public function setJob(\Alpixel\Bundle\CronBundle\Entity\CronJob $job) |
156 | 156 | { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * Get job |
162 | 162 | * |
163 | - * @return Alpixel\Bundle\CronBundle\Entity\CronJob |
|
163 | + * @return CronJob |
|
164 | 164 | */ |
165 | 165 | public function getJob() |
166 | 166 | { |
@@ -13,8 +13,8 @@ |
||
13 | 13 | protected function configure() |
14 | 14 | { |
15 | 15 | $this->setName("cron:enable-job") |
16 | - ->setDescription("Enables a cron job") |
|
17 | - ->addArgument("job", InputArgument::REQUIRED, "Name of the job to enable"); |
|
16 | + ->setDescription("Enables a cron job") |
|
17 | + ->addArgument("job", InputArgument::REQUIRED, "Name of the job to enable"); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -24,15 +24,15 @@ |
||
24 | 24 | $jobRepo = $em->getRepository('CronBundle:CronJob'); |
25 | 25 | |
26 | 26 | $job = $jobRepo->findOneByCommand($jobName); |
27 | - if(!$job) |
|
27 | + if (!$job) |
|
28 | 28 | { |
29 | - $output->writeln("Couldn't find a job by the name of " . $jobName); |
|
29 | + $output->writeln("Couldn't find a job by the name of ".$jobName); |
|
30 | 30 | return CronJobResult::FAILED; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $job->setEnabled(true); |
34 | 34 | $em->flush(); |
35 | 35 | |
36 | - $output->writeln("Enabled cron job by the name of " . $jobName); |
|
36 | + $output->writeln("Enabled cron job by the name of ".$jobName); |
|
37 | 37 | } |
38 | 38 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | public function doWrite($message, $newline) { |
17 | 17 | $this->backingStore .= $message; |
18 | - if($newline) { |
|
18 | + if ($newline) { |
|
19 | 19 | $this->backingStore .= "\n"; |
20 | 20 | } |
21 | 21 | } |
@@ -16,8 +16,8 @@ |
||
16 | 16 | protected function configure() |
17 | 17 | { |
18 | 18 | $this->setName("cron:pruneLogs") |
19 | - ->setDescription("Prunes the logs for each cron job, leaving only recent failures and the most recent success") |
|
20 | - ->addArgument('job', InputArgument::OPTIONAL, 'Operate only on this job'); |
|
19 | + ->setDescription("Prunes the logs for each cron job, leaving only recent failures and the most recent success") |
|
20 | + ->addArgument('job', InputArgument::OPTIONAL, 'Operate only on this job'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $em = $this->getContainer()->get("doctrine.orm.entity_manager"); |
26 | 26 | $job = $input->getArgument('job'); |
27 | 27 | |
28 | - if($job) |
|
28 | + if ($job) |
|
29 | 29 | { |
30 | 30 | $output->writeln("Pruning logs for cron job $job"); |
31 | 31 | } |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $output->writeln("Pruning logs for all cron jobs"); |
35 | 35 | } |
36 | 36 | |
37 | - if($job) |
|
37 | + if ($job) |
|
38 | 38 | { |
39 | 39 | $jobObj = $em->getRepository('CronBundle:CronJob')->findOneByCommand($job); |
40 | - if(!$jobObj) |
|
40 | + if (!$jobObj) |
|
41 | 41 | { |
42 | - $output->writeln("Couldn't find a job by the name of " . $job); |
|
42 | + $output->writeln("Couldn't find a job by the name of ".$job); |
|
43 | 43 | return CronJobResult::FAILED; |
44 | 44 | } |
45 | 45 |
@@ -28,8 +28,7 @@ discard block |
||
28 | 28 | if($job) |
29 | 29 | { |
30 | 30 | $output->writeln("Pruning logs for cron job $job"); |
31 | - } |
|
32 | - else |
|
31 | + } else |
|
33 | 32 | { |
34 | 33 | $output->writeln("Pruning logs for all cron jobs"); |
35 | 34 | } |
@@ -44,8 +43,7 @@ discard block |
||
44 | 43 | } |
45 | 44 | |
46 | 45 | $em->getRepository('CronBundle:CronJobResult')->deleteOldLogs($jobObj); |
47 | - } |
|
48 | - else |
|
46 | + } else |
|
49 | 47 | { |
50 | 48 | $em->getRepository('CronBundle:CronJobResult')->deleteOldLogs(); |
51 | 49 | } |
@@ -15,8 +15,8 @@ |
||
15 | 15 | protected function configure() |
16 | 16 | { |
17 | 17 | $this->setName("cron:disable-job") |
18 | - ->setDescription("Disables a cron job") |
|
19 | - ->addArgument("job", InputArgument::REQUIRED, "Name of the job to disable"); |
|
18 | + ->setDescription("Disables a cron job") |
|
19 | + ->addArgument("job", InputArgument::REQUIRED, "Name of the job to disable"); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -26,15 +26,15 @@ |
||
26 | 26 | $jobRepo = $em->getRepository('CronBundle:CronJob'); |
27 | 27 | |
28 | 28 | $job = $jobRepo->findOneByCommand($jobName); |
29 | - if(!$job) |
|
29 | + if (!$job) |
|
30 | 30 | { |
31 | - $output->writeln("Couldn't find a job by the name of " . $jobName); |
|
31 | + $output->writeln("Couldn't find a job by the name of ".$jobName); |
|
32 | 32 | return CronJobResult::FAILED; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $job->setEnabled(false); |
36 | 36 | $em->flush(); |
37 | 37 | |
38 | - $output->writeln("Disabled cron job by the name of " . $jobName); |
|
38 | + $output->writeln("Disabled cron job by the name of ".$jobName); |
|
39 | 39 | } |
40 | 40 | } |