]>
Commit | Line | Data |
---|---|---|
b8427f22 JB |
1 | <?php |
2 | ||
db9b6d8d | 3 | namespace Wallabag\CoreBundle\DataFixtures; |
b8427f22 | 4 | |
db9b6d8d JB |
5 | use Doctrine\Bundle\FixturesBundle\Fixture; |
6 | use Doctrine\Common\DataFixtures\DependentFixtureInterface; | |
b8427f22 | 7 | use Doctrine\Common\Persistence\ObjectManager; |
35359bd3 JB |
8 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
9 | use Symfony\Component\DependencyInjection\ContainerInterface; | |
b8427f22 | 10 | use Wallabag\CoreBundle\Entity\SiteCredential; |
db9b6d8d | 11 | use Wallabag\UserBundle\DataFixtures\UserFixtures; |
b8427f22 | 12 | |
9f0957b8 | 13 | class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface, ContainerAwareInterface |
b8427f22 | 14 | { |
35359bd3 JB |
15 | /** |
16 | * @var ContainerInterface | |
17 | */ | |
18 | private $container; | |
19 | ||
20 | public function setContainer(ContainerInterface $container = null) | |
21 | { | |
22 | $this->container = $container; | |
23 | } | |
24 | ||
b8427f22 JB |
25 | /** |
26 | * {@inheritdoc} | |
27 | */ | |
28 | public function load(ObjectManager $manager) | |
29 | { | |
30 | $credential = new SiteCredential($this->getReference('admin-user')); | |
35359bd3 JB |
31 | $credential->setHost('.super.com'); |
32 | $credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('.super')); | |
33 | $credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); | |
34 | ||
35 | $manager->persist($credential); | |
36 | ||
37 | $credential = new SiteCredential($this->getReference('admin-user')); | |
38 | $credential->setHost('paywall.example.com'); | |
39 | $credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('paywall.example')); | |
40 | $credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); | |
b8427f22 JB |
41 | |
42 | $manager->persist($credential); | |
43 | ||
44 | $manager->flush(); | |
45 | } | |
46 | ||
47 | /** | |
48 | * {@inheritdoc} | |
49 | */ | |
db9b6d8d | 50 | public function getDependencies() |
b8427f22 | 51 | { |
db9b6d8d JB |
52 | return [ |
53 | UserFixtures::class, | |
54 | ]; | |
b8427f22 JB |
55 | } |
56 | } |