Completed
Push — master ( fac3e1...87ae16 )
by Guillaume
02:53
created

CreerUtilisateurCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Starkerxp\UtilisateurBundle\Command;
4
5
use Starkerxp\StructureBundle\Command\LockCommand;
6
use Starkerxp\UtilisateurBundle\Entity\Utilisateur;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
10
class CreerUtilisateurCommand extends LockCommand
11
{
12
    public function traitement()
13
    {
14
        $user = Utilisateur::createFromPayload($this->input->getArgument("login"), ["roles" => ["ROLE_SUPER_ADMIN"]]);
15
        $user->setPlainPassword($this->input->getArgument("password"));
16
        $password = $this->getContainer()->get('security.password_encoder')
17
            ->encodePassword($user, $user->getPlainPassword());
18
        $user->setPassword($password);
19
20
        $this->getEntityManager()->persist($user);
21
        $this->getEntityManager()->flush();
22
    }
23
24
    protected function configure()
25
    {
26
        $this->setName('starkerxp:utilisateur:creer')
27
            ->addArgument('login', InputArgument::REQUIRED, "L'identifiant.")
28
            ->addArgument('password', InputArgument::REQUIRED, "Le mot de passe.")
29
            ->setDescription("Ajoute un nouvel utilisateur à la base de données");
30
    }
31
32
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
33