EthikTag/src/DataFixtures/UserFixtures.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2022-10-16 10:36:53 +02:00
<?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);
2023-01-07 22:07:15 +01:00
$user = new User();
$user->setPassword($this->passwordEncoder->hashPassword(
$user,
"rootroot"
));
$user->setEmail("sebastien.rubier@efs.fr")
->setRoles(["ROLE_USER","ROLE_ADMIN"]);
$manager->persist($user);
2022-10-16 10:36:53 +02:00
$manager->flush();
}
public static function getGroups(): array
{
return ['userGroup'];
}
}