wallabag/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginInstanceRuleFixtures.php

37 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Wallabag\CoreBundle\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
class IgnoreOriginInstanceRuleFixtures extends Fixture implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
foreach ($this->container->getParameter('wallabag_core.default_ignore_origin_instance_rules') as $ignore_origin_instance_rule) {
$newIgnoreOriginInstanceRule = new IgnoreOriginInstanceRule();
$newIgnoreOriginInstanceRule->setRule($ignore_origin_instance_rule['rule']);
$manager->persist($newIgnoreOriginInstanceRule);
}
$manager->flush();
}
}