48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\DataFixtures;
|
|
|
|
use App\Entity\User;
|
|
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
|
|
class UserFixtures extends Fixture implements FixtureGroupInterface
|
|
{
|
|
private $passwordEncoder;
|
|
|
|
public function __construct(UserPasswordHasherInterface $passwordEncoder)
|
|
{
|
|
$this->passwordEncoder = $passwordEncoder;
|
|
}
|
|
|
|
public function load(ObjectManager $manager)
|
|
{
|
|
$user = new User();
|
|
$user->setPassword($this->passwordEncoder->hashPassword(
|
|
$user,
|
|
"rootroot"
|
|
));
|
|
$user->setEmail("rmasson.pro@gmail.com")
|
|
->setRoles(["ROLE_USER","ROLE_ADMIN"]);
|
|
$manager->persist($user);
|
|
|
|
$user = new User();
|
|
$user->setPassword($this->passwordEncoder->hashPassword(
|
|
$user,
|
|
"rootroot"
|
|
));
|
|
$user->setEmail("sebastien.rubier@efs.fr")
|
|
->setRoles(["ROLE_USER","ROLE_ADMIN"]);
|
|
$manager->persist($user);
|
|
|
|
$manager->flush();
|
|
}
|
|
|
|
public static function getGroups(): array
|
|
{
|
|
return ['userGroup'];
|
|
}
|
|
}
|