wallabag/fixtures/InternalSettingFixtures.php
2024-03-30 01:49:52 +01:00

35 lines
1 KiB
PHP

<?php
namespace Wallabag\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Wallabag\Entity\InternalSetting;
class InternalSettingFixtures extends Fixture implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}
public function load(ObjectManager $manager): void
{
foreach ($this->container->getParameter('wallabag.default_internal_settings') as $setting) {
$newSetting = new InternalSetting();
$newSetting->setName($setting['name']);
$newSetting->setValue($setting['value']);
$newSetting->setSection($setting['section']);
$manager->persist($newSetting);
}
$manager->flush();
}
}