2018-11-23 22:09:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\DataFixtures;
|
|
|
|
|
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
|
|
use Doctrine\Common\Persistence\ObjectManager;
|
|
|
|
use App\Entity\Source\Primitive\Text\TextSource;
|
|
|
|
use App\Entity\Source\Primitive\Text\TextSourceInterface;
|
|
|
|
use App\DBAL\Types\SystemSlugType;
|
2018-12-31 21:18:03 +01:00
|
|
|
use App\Entity\Source\Complex\UserSource;
|
|
|
|
use App\Entity\Source\Complex\UserSourceInterface;
|
2019-01-01 22:36:55 +01:00
|
|
|
use App\Entity\Meta\Right;
|
2019-01-05 17:27:40 +01:00
|
|
|
use App\DBAL\Types\Meta\Right\LayerType;
|
|
|
|
use App\DBAL\Types\Meta\Right\CRUDType;
|
2019-01-01 22:36:55 +01:00
|
|
|
use App\Entity\Meta\RightInterface;
|
2019-01-03 21:04:48 +01:00
|
|
|
use App\Domain\SourceManagement\SourceRightManager;
|
2018-11-23 22:09:29 +01:00
|
|
|
|
2019-01-01 22:36:55 +01:00
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*
|
|
|
|
* @todo Create a collection class for all users
|
|
|
|
*/
|
2018-11-23 22:09:29 +01:00
|
|
|
class SourceFixtures extends Fixture
|
|
|
|
{
|
2019-01-01 22:36:55 +01:00
|
|
|
/**
|
|
|
|
* @var TextSourceInterface The example source for the impressum
|
|
|
|
*/
|
|
|
|
private $impressumSource;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var UserSourceInterface The UserSource which should be used for the anonymous user
|
|
|
|
*/
|
|
|
|
private $guestUserSource;
|
|
|
|
|
2019-01-03 21:04:48 +01:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @see \Doctrine\Common\DataFixtures\FixtureInterface::load()
|
|
|
|
*/
|
2018-11-23 22:09:29 +01:00
|
|
|
public function load(ObjectManager $manager)
|
|
|
|
{
|
2019-01-01 22:36:55 +01:00
|
|
|
$this->setGuestUserSource();
|
|
|
|
$this->setImpressumSource();
|
|
|
|
$manager->persist($this->impressumSource);
|
|
|
|
$manager->persist($this->getImpressumRight());
|
|
|
|
$manager->persist($this->guestUserSource);
|
2018-11-23 22:09:29 +01:00
|
|
|
$manager->flush();
|
|
|
|
}
|
|
|
|
|
2019-01-01 22:36:55 +01:00
|
|
|
private function setImpressumSource(): void
|
2018-11-23 22:09:29 +01:00
|
|
|
{
|
2019-01-01 22:36:55 +01:00
|
|
|
$this->impressumSource = new TextSource();
|
|
|
|
$this->impressumSource->setText('Example Impressum');
|
|
|
|
$this->impressumSource->setSlug(SystemSlugType::IMPRINT);
|
2018-11-23 22:09:29 +01:00
|
|
|
}
|
2018-12-31 21:18:03 +01:00
|
|
|
|
|
|
|
/**
|
2019-01-01 22:36:55 +01:00
|
|
|
* @todo Implement that right gets automaticly created by persisting of law
|
|
|
|
*
|
|
|
|
* @return RightInterface
|
2018-12-31 21:18:03 +01:00
|
|
|
*/
|
2019-01-01 22:36:55 +01:00
|
|
|
private function getImpressumRight(): RightInterface
|
2018-12-31 21:18:03 +01:00
|
|
|
{
|
2019-01-01 22:36:55 +01:00
|
|
|
$right = new Right();
|
2019-01-03 21:04:48 +01:00
|
|
|
$sourceRightManager = new SourceRightManager($this->impressumSource);
|
|
|
|
$sourceRightManager->addRight($right);
|
2019-01-01 22:36:55 +01:00
|
|
|
$right->setLayer(LayerType::SOURCE);
|
2019-01-16 21:22:18 +01:00
|
|
|
$right->setCrud(CRUDType::READ);
|
2019-01-01 22:36:55 +01:00
|
|
|
$right->setReciever($this->guestUserSource);
|
2018-12-31 21:18:03 +01:00
|
|
|
|
2019-01-01 22:36:55 +01:00
|
|
|
return $right;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function setGuestUserSource(): void
|
|
|
|
{
|
|
|
|
$this->guestUserSource = new UserSource();
|
|
|
|
$this->guestUserSource->setSlug(SystemSlugType::GUEST_USER);
|
2018-12-31 21:18:03 +01:00
|
|
|
}
|
2018-11-23 22:09:29 +01:00
|
|
|
}
|