Allowed guest users to access impressum

This commit is contained in:
Kevin Frantz
2019-01-01 22:36:55 +01:00
parent 3efa57f29a
commit 130682ef6c
3 changed files with 57 additions and 31 deletions

View File

@@ -9,36 +9,65 @@ use App\Entity\Source\Primitive\Text\TextSourceInterface;
use App\DBAL\Types\SystemSlugType;
use App\Entity\Source\Complex\UserSource;
use App\Entity\Source\Complex\UserSourceInterface;
use App\Entity\Meta\Right;
use App\DBAL\Types\LayerType;
use App\DBAL\Types\RightType;
use App\Entity\Meta\RightInterface;
/**
* @author kevinfrantz
*
* @todo Create a collection class for all users
*/
class SourceFixtures extends Fixture
{
/**
* @var TextSourceInterface The example source for the impressum
*/
private $impressumSource;
/**
* @var UserSourceInterface The UserSource which should be used for the anonymous user
*/
private $guestUserSource;
public function load(ObjectManager $manager)
{
$manager->persist($this->getImpressum());
$manager->persist($this->getGuestUser());
$this->setGuestUserSource();
$this->setImpressumSource();
$manager->persist($this->impressumSource);
$manager->persist($this->getImpressumRight());
$manager->persist($this->guestUserSource);
$manager->flush();
}
/**
* @return TextSourceInterface The example source for the impressum
*/
private function getImpressum(): TextSourceInterface
private function setImpressumSource(): void
{
$source = new TextSource();
$source->setText('Example Impressum');
$source->setSlug(SystemSlugType::IMPRINT);
return $source;
$this->impressumSource = new TextSource();
$this->impressumSource->setText('Example Impressum');
$this->impressumSource->setSlug(SystemSlugType::IMPRINT);
}
/**
* @return UserSourceInterface The UserSource which should be used for the anonymous user
* @todo Implement that right gets automaticly created by persisting of law
*
* @return RightInterface
*/
private function getGuestUser(): UserSourceInterface
private function getImpressumRight(): RightInterface
{
$source = new UserSource();
$source->setSlug(SystemSlugType::GUEST_USER);
$right = new Right();
$right->setSource($this->impressumSource);
$right->setLaw($this->impressumSource->getLaw());
$right->setLayer(LayerType::SOURCE);
$right->setType(RightType::READ);
$right->setReciever($this->guestUserSource);
return $source;
return $right;
}
private function setGuestUserSource(): void
{
$this->guestUserSource = new UserSource();
$this->guestUserSource->setSlug(SystemSlugType::GUEST_USER);
}
}