Completed
Push — master ( 886ffb...8e4bc0 )
by Louis
107:54 queued 52:50
created

PhotoRemoveCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace KI\UserBundle\Command;
3
4
use KI\UserBundle\Entity\User;
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class PhotoRemoveCommand extends ContainerAwareCommand
11
{
12
    protected function configure()
13
    {
14
        $this
15
            ->setName('upont:remove:photo')
16
            ->setDescription('Remove the photo of a user')
17
            ->addArgument('username', InputArgument::REQUIRED, 'The user whose photo is to be removed.');
18
    }
19
20
    protected function execute(InputInterface $input, OutputInterface $output)
21
    {
22
        $em = $this->getContainer()->get('doctrine')->getManager();
23
        $repo = $this->getContainer()->get('doctrine')->getRepository(User::class);
24
        $user = $repo->findOneByUsername($input->getArgument('username'));
25
        $user->setImage(null);
26
        $em->flush();
27
    }
28
}
29