diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php')
-rw-r--r-- | src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php new file mode 100644 index 00000000..fd129829 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php | |||
@@ -0,0 +1,39 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\DataFixtures; | ||
4 | |||
5 | use Craue\ConfigBundle\Entity\Setting; | ||
6 | use Doctrine\Bundle\FixturesBundle\Fixture; | ||
7 | use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||
8 | use Doctrine\Common\Persistence\ObjectManager; | ||
9 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
10 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
11 | |||
12 | class SettingFixtures extends Fixture implements ContainerAwareInterface | ||
13 | { | ||
14 | /** | ||
15 | * @var ContainerInterface | ||
16 | */ | ||
17 | private $container; | ||
18 | |||
19 | public function setContainer(ContainerInterface $container = null) | ||
20 | { | ||
21 | $this->container = $container; | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * {@inheritdoc} | ||
26 | */ | ||
27 | public function load(ObjectManager $manager) | ||
28 | { | ||
29 | foreach ($this->container->getParameter('wallabag_core.default_internal_settings') as $setting) { | ||
30 | $newSetting = new Setting(); | ||
31 | $newSetting->setName($setting['name']); | ||
32 | $newSetting->setValue($setting['value']); | ||
33 | $newSetting->setSection($setting['section']); | ||
34 | $manager->persist($newSetting); | ||
35 | } | ||
36 | |||
37 | $manager->flush(); | ||
38 | } | ||
39 | } | ||