]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php
Merge pull request #3966 from wallabag/prepare-2.3.8
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / DataFixtures / ORM / LoadSiteCredentialData.php
1 <?php
2
3 namespace Wallabag\CoreBundle\DataFixtures\ORM;
4
5 use Doctrine\Common\DataFixtures\AbstractFixture;
6 use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7 use Doctrine\Common\Persistence\ObjectManager;
8 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
10 use Wallabag\CoreBundle\Entity\SiteCredential;
11
12 class LoadSiteCredentialData extends AbstractFixture implements OrderedFixtureInterface, 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 $credential = new SiteCredential($this->getReference('admin-user'));
30 $credential->setHost('.super.com');
31 $credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('.super'));
32 $credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar'));
33
34 $manager->persist($credential);
35
36 $credential = new SiteCredential($this->getReference('admin-user'));
37 $credential->setHost('paywall.example.com');
38 $credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('paywall.example'));
39 $credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar'));
40
41 $manager->persist($credential);
42
43 $manager->flush();
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function getOrder()
50 {
51 return 50;
52 }
53 }