From: Raphaël Gertz Date: Mon, 11 Dec 2023 03:05:01 +0000 (+0100) Subject: Pass slugger to constructor X-Git-Tag: 0.2~43 X-Git-Url: https://git.rapsys.eu/blogbundle/commitdiff_plain/6f9d098d71f63f2127f5079688b0549bb8096186?hp=98b2037f369687f34a62317aadae1f5a66c12ff4 Pass slugger to constructor Rename disabled to enable Cleanup --- 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