2017-05-01 20:13:35 +00:00
|
|
|
<?php
|
|
|
|
|
2018-11-26 19:00:01 +00:00
|
|
|
namespace Wallabag\CoreBundle\DataFixtures;
|
2017-05-01 20:13:35 +00:00
|
|
|
|
2018-11-26 19:00:01 +00:00
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
|
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
2020-06-15 06:25:59 +00:00
|
|
|
use Doctrine\Persistence\ObjectManager;
|
2019-04-24 13:28:15 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
2017-05-01 20:13:35 +00:00
|
|
|
use Wallabag\CoreBundle\Entity\SiteCredential;
|
2018-11-26 19:00:01 +00:00
|
|
|
use Wallabag\UserBundle\DataFixtures\UserFixtures;
|
2017-05-01 20:13:35 +00:00
|
|
|
|
2019-05-15 12:38:07 +00:00
|
|
|
class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface, ContainerAwareInterface
|
2017-05-01 20:13:35 +00:00
|
|
|
{
|
2019-04-24 13:28:15 +00:00
|
|
|
/**
|
|
|
|
* @var ContainerInterface
|
|
|
|
*/
|
|
|
|
private $container;
|
|
|
|
|
|
|
|
public function setContainer(ContainerInterface $container = null)
|
|
|
|
{
|
|
|
|
$this->container = $container;
|
|
|
|
}
|
|
|
|
|
2017-05-01 20:13:35 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2020-06-15 06:25:59 +00:00
|
|
|
public function load(ObjectManager $manager): void
|
2017-05-01 20:13:35 +00:00
|
|
|
{
|
|
|
|
$credential = new SiteCredential($this->getReference('admin-user'));
|
2019-04-24 13:28:15 +00:00
|
|
|
$credential->setHost('.super.com');
|
|
|
|
$credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('.super'));
|
|
|
|
$credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar'));
|
|
|
|
|
|
|
|
$manager->persist($credential);
|
|
|
|
|
|
|
|
$credential = new SiteCredential($this->getReference('admin-user'));
|
|
|
|
$credential->setHost('paywall.example.com');
|
|
|
|
$credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('paywall.example'));
|
|
|
|
$credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar'));
|
2017-05-01 20:13:35 +00:00
|
|
|
|
|
|
|
$manager->persist($credential);
|
|
|
|
|
|
|
|
$manager->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2018-11-26 19:00:01 +00:00
|
|
|
public function getDependencies()
|
2017-05-01 20:13:35 +00:00
|
|
|
{
|
2018-11-26 19:00:01 +00:00
|
|
|
return [
|
|
|
|
UserFixtures::class,
|
|
|
|
];
|
2017-05-01 20:13:35 +00:00
|
|
|
}
|
|
|
|
}
|