1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Command; |
4
|
|
|
|
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
|
|
|
/** |
11
|
|
|
* Class AdminCreateCommand |
12
|
|
|
* @package AppBundle\Command |
13
|
|
|
*/ |
14
|
|
|
class AdminCreateCommand extends ContainerAwareCommand |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* {@inheritdoc} |
18
|
|
|
*/ |
19
|
27 |
|
protected function configure() |
20
|
|
|
{ |
21
|
27 |
|
$this |
22
|
27 |
|
->setName('app:admin_create') |
23
|
27 |
|
->setDescription('Create admin user') |
24
|
27 |
|
->setDefinition(array( |
25
|
27 |
|
new InputArgument('email', InputArgument::REQUIRED, 'The email'), |
26
|
27 |
|
new InputArgument('password', InputArgument::REQUIRED, 'The password'), |
27
|
27 |
|
new InputArgument('firstName', InputArgument::REQUIRED, 'The first name'), |
28
|
27 |
|
new InputArgument('lastName', InputArgument::REQUIRED, 'The last name') |
29
|
27 |
|
)); |
30
|
|
|
|
31
|
27 |
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
37
|
|
|
{ |
38
|
|
|
$email = $input->getArgument('email'); |
39
|
|
|
$password = $input->getArgument('password'); |
40
|
|
|
$firstName = $input->getArgument('firstName'); |
41
|
|
|
$lastName = $input->getArgument('lastName'); |
42
|
|
|
|
43
|
|
|
$this->getContainer()->get('app.admin.creator') |
44
|
|
|
->create($email, $password, $firstName, $lastName); |
45
|
|
|
|
46
|
|
|
$output->writeln(sprintf('User <comment>%s</comment> was created/updated', $firstName.' '.$lastName)); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|