|
@@ -13,21 +13,20 @@ use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface;
|
|
|
*/
|
|
|
class UserManager
|
|
|
{
|
|
|
- protected $em;
|
|
|
- protected $passwordEncoder;
|
|
|
- protected $tokenGenerator;
|
|
|
/**
|
|
|
* UserManager constructor.
|
|
|
* @param EntityManagerInterface $em
|
|
|
*/
|
|
|
- public function __construct(EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, TokenGeneratorInterface $tokenGenerator)
|
|
|
+ public function __construct(
|
|
|
+ protected EntityManagerInterface $em,
|
|
|
+ protected UserPasswordHasherInterface $passwordEncoder,
|
|
|
+ protected TokenGeneratorInterface $tokenGenerator
|
|
|
+ )
|
|
|
{
|
|
|
- $this->em = $em;
|
|
|
- $this->passwordEncoder = $passwordEncoder;
|
|
|
- $this->tokenGenerator = $tokenGenerator;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- public function createUser($username, $password, $nom, $prenom, $mail, $roles, $activated)
|
|
|
+ public function createUser(string $username, string $password, string $nom, string $prenom, string $mail, array $roles, bool $activated): void
|
|
|
{
|
|
|
$user = new User();
|
|
|
$options = new Profile();
|
|
@@ -42,7 +41,7 @@ class UserManager
|
|
|
$this->enregistrerUser($user);
|
|
|
}
|
|
|
|
|
|
- public function register(User $user)
|
|
|
+ public function register(User $user): void
|
|
|
{
|
|
|
$user->setActivated(false);
|
|
|
$user->setRoles(array('ROLE_USER'));
|
|
@@ -50,12 +49,12 @@ class UserManager
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function resetPassword(User $user)
|
|
|
+ public function resetPassword(User $user): void
|
|
|
{
|
|
|
$user->setActivated($user);
|
|
|
$this->enregistrerUser($user);
|
|
|
}
|
|
|
- public function enregistrerUser (User $user)
|
|
|
+ public function enregistrerUser (User $user): void
|
|
|
{
|
|
|
$encoded = $this->passwordEncoder->hashPassword($user, $user->getPassword());
|
|
|
$user->setPassword($encoded);
|
|
@@ -69,18 +68,18 @@ class UserManager
|
|
|
$this->em->flush();
|
|
|
}
|
|
|
|
|
|
- public function editUser ()
|
|
|
+ public function editUser (): void
|
|
|
{
|
|
|
$this->em->flush();
|
|
|
}
|
|
|
|
|
|
- public function removeUser(User $user)
|
|
|
+ public function removeUser(User $user): void
|
|
|
{
|
|
|
$this->em->remove($user);
|
|
|
$this->em->flush();
|
|
|
}
|
|
|
|
|
|
- public function generateToken(User $user)
|
|
|
+ public function generateToken(User $user): void
|
|
|
{
|
|
|
$user->setToken($this->tokenGenerator->generateToken());
|
|
|
}
|