Completed
Branch master (38bcb9)
by Matthew
02:36
created

ResetCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Dtc\QueueBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class ResetCommand extends ContainerAwareCommand
10
{
11
    protected function configure()
12
    {
13
        $this
14
            ->setName('dtc:queue:reset')
15
            ->setDescription('Reset jobs with error or stalled status');
16
    }
17
18
    protected function execute(InputInterface $input, OutputInterface $output)
19
    {
20
        $container = $this->getContainer();
21
        $jobManager = $container->get('dtc_queue.job_manager');
22
        $countError = $jobManager->resetErroneousJobs();
23
        $countStalled = $jobManager->resetStalledJobs();
24
        $output->writeln("$countError job(s) in status 'error' reset");
25
        $output->writeln("$countStalled job(s) in status 'running' reset");
26
    }
27
}
28