Optimized for SPA

This commit is contained in:
Kevin Frantz
2019-01-05 23:52:37 +01:00
parent 9e685260e9
commit bccd6efaff
393 changed files with 253 additions and 37 deletions

View File

View File

@@ -0,0 +1,51 @@
<?php
namespace App\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use App\Entity\User;
use FOS\UserBundle\Doctrine\UserManager;
use App\Entity\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
/**
* Never execute this fixture on a livesystem!
*
* @author kevinfrantz
*/
class DummyFixtures extends Fixture implements ContainerAwareInterface
{
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function load(ObjectManager $manager)
{
$manager->persist($this->getTestUser());
$manager->flush();
}
protected function getTestUser(): UserInterface
{
/**
* @var UserManager
*/
$userManager = $this->container->get('fos_user.user_manager');
/**
* @var User
*/
$testUser = $userManager->createUser();
$testUser->setEmail('test@test.de');
$testUser->setUsername('test');
$testUser->setPlainPassword('test');
$testUser->setEnabled(true);
$userManager->updateUser($testUser);
return $testUser;
}
}

View File

@@ -0,0 +1,79 @@
<?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;
use App\Entity\Source\Complex\UserSource;
use App\Entity\Source\Complex\UserSourceInterface;
use App\Entity\Meta\Right;
use App\DBAL\Types\Meta\Right\LayerType;
use App\DBAL\Types\Meta\Right\CRUDType;
use App\Entity\Meta\RightInterface;
use App\Domain\SourceManagement\SourceRightManager;
/**
* @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;
/**
* {@inheritdoc}
*
* @see \Doctrine\Common\DataFixtures\FixtureInterface::load()
*/
public function load(ObjectManager $manager)
{
$this->setGuestUserSource();
$this->setImpressumSource();
$manager->persist($this->impressumSource);
$manager->persist($this->getImpressumRight());
$manager->persist($this->guestUserSource);
$manager->flush();
}
private function setImpressumSource(): void
{
$this->impressumSource = new TextSource();
$this->impressumSource->setText('Example Impressum');
$this->impressumSource->setSlug(SystemSlugType::IMPRINT);
}
/**
* @todo Implement that right gets automaticly created by persisting of law
*
* @return RightInterface
*/
private function getImpressumRight(): RightInterface
{
$right = new Right();
$sourceRightManager = new SourceRightManager($this->impressumSource);
$sourceRightManager->addRight($right);
$right->setLayer(LayerType::SOURCE);
$right->setType(CRUDType::READ);
$right->setReciever($this->guestUserSource);
return $right;
}
private function setGuestUserSource(): void
{
$this->guestUserSource = new UserSource();
$this->guestUserSource->setSlug(SystemSlugType::GUEST_USER);
}
}