Last active
September 15, 2021 23:34
-
-
Save bernard-ng/1c7faf78b74e3faa52382d93abe6a1f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
{ | |
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment