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.
<?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 <bernard@devscast.tech>
*/
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