Conditions | 4 |
Paths | 6 |
Total Lines | 31 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | protected function execute(InputInterface $input, OutputInterface $output) |
||
21 | { |
||
22 | $em = $this->getContainer()->get('doctrine.orm.entity_manager'); |
||
23 | $job = $input->getArgument('job'); |
||
24 | |||
25 | if ($job) { |
||
26 | $output->writeln("Pruning logs for cron job $job"); |
||
27 | } else { |
||
28 | $output->writeln('Pruning logs for all cron jobs'); |
||
29 | } |
||
30 | |||
31 | if ($job) { |
||
32 | $jobObj = $em->getRepository('CronBundle:CronJob')->findOneByCommand($job); |
||
33 | if (!$jobObj) { |
||
34 | $output->writeln("Couldn't find a job by the name of ".$job); |
||
35 | |||
36 | return CronJobResult::FAILED; |
||
37 | } |
||
38 | |||
39 | $em->getRepository('CronBundle:CronJobResult')->deleteOldLogs($jobObj); |
||
40 | } else { |
||
41 | $em->getRepository('CronBundle:CronJobResult')->deleteOldLogs(); |
||
42 | } |
||
43 | |||
44 | // Flush the EM |
||
45 | $em->flush(); |
||
46 | |||
47 | $output->writeln('Logs pruned successfully'); |
||
48 | |||
49 | return CronJobResult::SUCCEEDED; |
||
50 | } |
||
51 | } |
||
52 |