From 6f9d098d71f63f2127f5079688b0549bb8096186 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Mon, 11 Dec 2023 04:05:01 +0100 Subject: [PATCH] Pass slugger to constructor Rename disabled to enable Cleanup --- Fixture/BlogFixture.php | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/Fixture/BlogFixture.php b/Fixture/BlogFixture.php index 5b44ebc..0e36170 100644 --- a/Fixture/BlogFixture.php +++ b/Fixture/BlogFixture.php @@ -13,11 +13,6 @@ namespace Rapsys\BlogBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -use Symfony\Component\PasswordHasher\PasswordHasherInterface; -use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory; use Rapsys\PackBundle\Util\SluggerUtil; @@ -30,29 +25,21 @@ use Rapsys\BlogBundle\Entity\KeywordTranslation; use Rapsys\BlogBundle\Entity\Article; use Rapsys\BlogBundle\Entity\ArticleTranslation; -#use Rapsys\AirBundle\Entity\Location; -#use Rapsys\AirBundle\Entity\Slot; - -class BlogFixture extends Fixture implements ContainerAwareInterface { - /** - * @var ContainerInterface - */ - private ContainerInterface $container; - - /** - * @var PasswordHasherFactory - */ - private PasswordHasherFactory $hasher; - +/** + * {@inheritDoc} + */ +class BlogFixture extends Fixture { /** * @var Rapsys\PackBundle\Util\SluggerUtil */ private SluggerUtil $slugger; - public function setContainer(ContainerInterface $container = null) { - $this->container = $container; - $this->hasher = $container->get('security.password_hasher_factory'); - $this->slugger = $container->get('rapsys_pack.slugger_util'); + /** + * Constructor + */ + public function __construct(SluggerUtil $slugger) { + //Set slugger + $this->slugger = $slugger; } /** @@ -104,7 +91,7 @@ class BlogFixture extends Fixture implements ContainerAwareInterface { 'forename' => 'Raphaël', 'surname' => 'Gertz', 'active' => true, - 'disabled' => false, + 'enable' => false, 'pseudonym' => 'Rapsys', 'slug' => $this->slugger->slug('Raphaël Gertz (rapsys)'), 'translations' => [ @@ -117,8 +104,7 @@ class BlogFixture extends Fixture implements ContainerAwareInterface { //Create users $users = []; foreach($userTree as $userData) { - $user = new User($userData['mail'], $userData['password'], $civilitys[$userData['civility']], $userData['forename'], $userData['surname'], $userData['active'], $userData['disabled'], $userData['pseudonym'], $userData['slug']); - #$user->setPassword($this->hasher->hashPassword($user, $userData['password'])); + $user = new User($userData['mail'], $userData['password'], $civilitys[$userData['civility']], $userData['forename'], $userData['surname'], $userData['active'], $userData['enable'], $userData['pseudonym'], $userData['slug']); $user->addGroup($groups[$userData['group']]); $manager->persist($user); //Flush to get the id -- 2.41.1