MediaCleanupCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
namespace Alpixel\Bundle\MediaBundle\Command;
4
5
use Alpixel\Bundle\CronBundle\Annotation\CronJob;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * @CronJob("P1D")
12
 */
13
class MediaCleanupCommand extends ContainerAwareCommand
14
{
15
    public function configure()
16
    {
17
        $this->setName('alpixel:media:cleanup')
18
             ->setDescription('Cleaning unused media');
19
    }
20
21
    public function execute(InputInterface $input, OutputInterface $output)
22
    {
23
        $container = $this->getContainer();
24
25
        $container->get('doctrine.orm.entity_manager')
26
                  ->getRepository('AlpixelMediaBundle:Media')
27
                  ->findExpiredMedias();
28
29
        $medias = $container->get('alpixel_media.manager')->cleanup();
30
        $output->writeln(sprintf('%s medias deleted', $medias));
31
    }
32
}