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