| Conditions | 4 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 21 | { |
||
| 22 | |||
| 23 | $doctrine = $this->getContainer()->get('doctrine'); |
||
| 24 | |||
| 25 | $crons = $doctrine->getManager()->getRepository('AppBundle:Action')->findBy(['type'=>'cron']); |
||
| 26 | |||
| 27 | /** @var Action $cronAction */ |
||
| 28 | foreach ($crons as $cronAction) { |
||
| 29 | $args = json_decode($cronAction->getArguments(), true); |
||
| 30 | |||
| 31 | if (isset($args['disabled'])) { |
||
| 32 | continue; |
||
| 33 | } |
||
| 34 | |||
| 35 | if (time() - $args['last'] >= $args['every']) { |
||
| 36 | $output->writeln('Running '.$cronAction->getExecutor().' for "'. |
||
| 37 | $cronAction->getDevice()->getName().'" device'); |
||
| 38 | $this-> |
||
| 39 | getContainer()-> |
||
| 40 | get('actions')-> |
||
| 41 | executeReal( |
||
| 42 | $cronAction, |
||
| 43 | 'cron', |
||
| 44 | ['container'=>$this->getContainer()] |
||
| 45 | ); |
||
| 46 | $args['last'] = time(); |
||
| 47 | $cronAction->setArguments(json_encode($args)); |
||
| 48 | $doctrine->getManager()->persist($cronAction); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | $doctrine->getManager()->flush(); |
||
| 53 | } |
||
| 54 | } |
||
| 55 |