mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 00:24:59 +00:00
- Inject parameters directly instead of getting from container - User PasswordHasher instead of EncoderFactory - set parameters directly and correctly encode values to json
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
|
|
|
use Chill\MainBundle\Command\LoadCountriesCommand;
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
|
|
|
|
/**
|
|
* Load countries into database.
|
|
*/
|
|
class LoadCountries extends Fixture implements OrderedFixtureInterface
|
|
{
|
|
private array $availableLanguages;
|
|
public function __construct(private readonly ParameterBagInterface $parameterBag)
|
|
{
|
|
$this->availableLanguages = $this->parameterBag->get('chill_main.available_languages');
|
|
}
|
|
public function getOrder(): int
|
|
{
|
|
return 20;
|
|
}
|
|
|
|
public function load(ObjectManager $manager): void
|
|
{
|
|
echo "loading countries... \n";
|
|
|
|
$languages = $this->availableLanguages;
|
|
|
|
foreach (LoadCountriesCommand::prepareCountryList($languages) as $country) {
|
|
$manager->persist($country);
|
|
}
|
|
|
|
$manager->flush();
|
|
}
|
|
}
|