mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-16 15:24:26 +00:00
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
|
|
|
use Chill\MainBundle\Command\LoadCountriesCommand;
|
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
/**
|
|
* Load countries into database.
|
|
*/
|
|
class LoadCountries extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
|
{
|
|
/**
|
|
* @var ContainerInterface
|
|
*/
|
|
private $container;
|
|
|
|
public function getOrder()
|
|
{
|
|
return 20;
|
|
}
|
|
|
|
public function load(ObjectManager $manager)
|
|
{
|
|
echo "loading countries... \n";
|
|
|
|
$languages = $this->container->getParameter('chill_main.available_languages');
|
|
|
|
foreach (LoadCountriesCommand::prepareCountryList($languages) as $country) {
|
|
$manager->persist($country);
|
|
}
|
|
|
|
$manager->flush();
|
|
}
|
|
|
|
public function setContainer(?ContainerInterface $container = null)
|
|
{
|
|
$this->container = $container;
|
|
}
|
|
}
|