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

CreerUtilisateurCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 2
cbo 5
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A traitement() 0 11 1
A configure() 0 7 1
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