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;
|
2023-12-30 22:32:36 +00:00
|
|
|
use Wallabag\CoreBundle\Entity\User;
|
2022-04-24 15:48:59 +00:00
|
|
|
use Wallabag\CoreBundle\Helper\CryptoProxy;
|
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;
|
|
|
|
|
2024-02-19 08:31:30 +00:00
|
|
|
public function setContainer(?ContainerInterface $container = null)
|
2019-04-24 13:28:15 +00:00
|
|
|
{
|
|
|
|
$this->container = $container;
|
|
|
|
}
|
|
|
|
|
2020-06-15 06:25:59 +00:00
|
|
|
public function load(ObjectManager $manager): void
|
2017-05-01 20:13:35 +00:00
|
|
|
{
|
2023-08-05 16:25:03 +00:00
|
|
|
$credential = new SiteCredential($this->getReference('admin-user', User::class));
|
2019-04-24 13:28:15 +00:00
|
|
|
$credential->setHost('.super.com');
|
2022-04-24 15:48:59 +00:00
|
|
|
$credential->setUsername($this->container->get(CryptoProxy::class)->crypt('.super'));
|
|
|
|
$credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar'));
|
2019-04-24 13:28:15 +00:00
|
|
|
|
|
|
|
$manager->persist($credential);
|
|
|
|
|
2023-08-05 16:25:03 +00:00
|
|
|
$credential = new SiteCredential($this->getReference('admin-user', User::class));
|
2019-04-24 13:28:15 +00:00
|
|
|
$credential->setHost('paywall.example.com');
|
2022-04-24 15:48:59 +00:00
|
|
|
$credential->setUsername($this->container->get(CryptoProxy::class)->crypt('paywall.example'));
|
|
|
|
$credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar'));
|
2017-05-01 20:13:35 +00:00
|
|
|
|
|
|
|
$manager->persist($credential);
|
|
|
|
|
|
|
|
$manager->flush();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|