Skip to content

Instantly share code, notes, and snippets.

@bernard-ng
Last active September 15, 2021 23:34
Show Gist options
  • Save bernard-ng/1c7faf78b74e3faa52382d93abe6a1f3 to your computer and use it in GitHub Desktop.
Save bernard-ng/1c7faf78b74e3faa52382d93abe6a1f3 to your computer and use it in GitHub Desktop.

Revisions

  1. bernard-ng revised this gist Sep 15, 2021. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions DisallowedCountryFixtures.php
    Original file line number Diff line number Diff line change
    @@ -12,14 +12,10 @@
    /**
    * Class DisallowCountryFixtures
    * @package App\DataFixtures
    * @author bernard-ng <[email protected]>
    * @author bernard-ng <[email protected]>
    */
    class DisallowCountryFixtures extends Fixture
    {
    /**
    * @param ObjectManager $manager
    * @author bernard-ng <[email protected]>
    */
    public function load(ObjectManager $manager): void
    {
    $countries = Countries::getNames();
  2. bernard-ng created this gist Feb 28, 2021.
    35 changes: 35 additions & 0 deletions DisallowedCountryFixtures.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <?php

    declare(strict_types=1);

    namespace App\DataFixtures;

    use App\Domain\Application\Entity\DisallowCountry;
    use Doctrine\Bundle\FixturesBundle\Fixture;
    use Doctrine\Persistence\ObjectManager;
    use Symfony\Component\Intl\Countries;

    /**
    * Class DisallowCountryFixtures
    * @package App\DataFixtures
    * @author bernard-ng <[email protected]>
    */
    class DisallowCountryFixtures extends Fixture
    {
    /**
    * @param ObjectManager $manager
    * @author bernard-ng <[email protected]>
    */
    public function load(ObjectManager $manager): void
    {
    $countries = Countries::getNames();
    foreach ($countries as $iso => $name) {
    $data = (new DisallowCountry())
    ->setName($name)
    ->setIso2($iso)
    ->setHasAccess(true);
    $manager->persist($data);
    }
    $manager->flush();
    }
    }