src/DataFixtures/CategoryFixture.php
/**
     * Load three types of Categories to DB.
     *
     * @see     3 $categories[5] to use its references in ReductionFixture
     * @see    https://github.com/fzaninotto/Faker
     *
     * @throws Exception Datetime Exception
     */
Load three types of Categories to DB.

@throws Exception Datetime Exception
Load three types of Categories to DB . @throws Exception Datetime Exception
public function load(ObjectManager $manager): void
    {
        $faker = Faker\Factory::create($this->container->getParameter('faker_locale'));
        foreach ($this->getCategories() as $index => $name) {
            $category = new Category();
            $category->setUuid(Uuid::uuid4());
            $category->setCreatedAt($this->clock->getNowInDateTime());
            $category->setUpdatedAt(null);
            $category->setName(ucfirst($name))
                ->setDescription($faker->sentence(20))
            ;
            $manager->persist($category);
            $this->addReference(self::CATEGORY_REFERENCE.$index, $category);
        }
        $manager->flush();
    }
public function load ( ObjectManager $ manager ) : void { $ faker = Faker \ Factory :: create ( $ this -> container -> getParameter ( 'faker_locale' ) ) ; foreach ( $ this -> getCategories ( ) as $ index => $ name ) { $ category = new Category ( ) ; $ category -> setUuid ( Uuid :: uuid4 ( ) ) ; $ category -> setCreatedAt ( $ this -> clock -> getNowInDateTime ( ) ) ; $ category -> setUpdatedAt ( null ) ; $ category -> setName ( ucfirst ( $ name ) ) -> setDescription ( $ faker -> sentence ( 20 ) ) ; $ manager -> persist ( $ category ) ; $ this -> addReference ( self :: CATEGORY_REFERENCE . $ index , $ category ) ; } $ manager -> flush ( ) ; }
Load three types of Categories to DB.
Load three types of Categories to DB .