2016-01-21 12:23:45 +01:00
|
|
|
<?php
|
|
|
|
|
2024-02-19 01:30:12 +01:00
|
|
|
namespace Wallabag\DataFixtures;
|
2016-01-21 12:23:45 +01:00
|
|
|
|
2018-11-26 20:00:01 +01:00
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
2020-06-15 08:25:59 +02:00
|
|
|
use Doctrine\Persistence\ObjectManager;
|
2017-06-02 10:19:33 +02:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
2024-02-19 01:30:12 +01:00
|
|
|
use Wallabag\Entity\InternalSetting;
|
2016-01-21 12:23:45 +01:00
|
|
|
|
2019-08-08 15:19:53 +02:00
|
|
|
class InternalSettingFixtures extends Fixture implements ContainerAwareInterface
|
2016-01-21 12:23:45 +01:00
|
|
|
{
|
2017-06-02 10:19:33 +02:00
|
|
|
/**
|
|
|
|
* @var ContainerInterface
|
|
|
|
*/
|
|
|
|
private $container;
|
|
|
|
|
2024-02-19 09:31:30 +01:00
|
|
|
public function setContainer(?ContainerInterface $container = null)
|
2017-06-02 10:19:33 +02:00
|
|
|
{
|
|
|
|
$this->container = $container;
|
|
|
|
}
|
|
|
|
|
2020-06-15 08:25:59 +02:00
|
|
|
public function load(ObjectManager $manager): void
|
2016-01-21 12:23:45 +01:00
|
|
|
{
|
2024-02-20 00:47:53 +01:00
|
|
|
foreach ($this->container->getParameter('wallabag.default_internal_settings') as $setting) {
|
2019-08-08 15:19:53 +02:00
|
|
|
$newSetting = new InternalSetting();
|
2016-01-21 12:23:45 +01:00
|
|
|
$newSetting->setName($setting['name']);
|
|
|
|
$newSetting->setValue($setting['value']);
|
|
|
|
$newSetting->setSection($setting['section']);
|
|
|
|
$manager->persist($newSetting);
|
|
|
|
}
|
|
|
|
|
|
|
|
$manager->flush();
|
|
|
|
}
|
|
|
|
}
|