Completed
Push — master ( bfe5d7...c95e3e )
by Paweł
15s
created

CreateUserCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2018 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2018 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\Command;
16
17
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
18
use FOS\UserBundle\Command\CreateUserCommand as BaseCreateUserCommand;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
22
class CreateUserCommand extends BaseCreateUserCommand
23
{
24
    protected static $defaultName = 'fos:user:create';
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31
        try {
32
            parent::execute($input, $output);
33
        } catch (UniqueConstraintViolationException $e) {
34
            $output->writeln(sprintf('<error>User with username %s already exists!</error>', $input->getArgument('username')));
35
        }
36
    }
37
}
38