mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Optimized for SPA
This commit is contained in:
0
application/symfony/src/Controller/.gitignore
vendored
Normal file
0
application/symfony/src/Controller/.gitignore
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface APIControllerInterface extends CRUDControllerInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request HTTP Method GET with filtering parameters
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function list(Request $request): Response;
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API;
|
||||
|
||||
use App\Controller\AbstractController;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractAPIController extends AbstractController implements APIControllerInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @see https://de.wikipedia.org/wiki/CRUD
|
||||
*/
|
||||
interface CRUDControllerInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request HTTP Method POST with the object attributes as parameters
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create(Request $request): Response;
|
||||
|
||||
/**
|
||||
* @param Request $request HTTP Method GET
|
||||
* @param int|string $identifier The slug or id of the object
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function read(Request $request, $identifier): Response;
|
||||
|
||||
/**
|
||||
* @param Request $request HTTP Method PUT
|
||||
* @param int|string $identifier The slug or id of the object
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request, $identifier): Response;
|
||||
|
||||
/**
|
||||
* @param Request $request HTTP Method DELETE with the object attributes as parameters
|
||||
* @param int|string $identifier The slug or id of the object
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function delete(Request $request, $identifier): Response;
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HeredityApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class LawApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class MemberApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RightApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Source;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use App\Entity\Source\PureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SourceApiController extends AbstractAPIController
|
||||
{
|
||||
/**
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"GET"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::read()
|
||||
*/
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/source.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"POST","GET"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::create()
|
||||
*/
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
if (Request::METHOD_POST === $request->getMethod()) {
|
||||
$response = new Response();
|
||||
$response->setContent('Post Request!');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response = new Response();
|
||||
$response->setContent('GET Request!');
|
||||
|
||||
return $response;
|
||||
|
||||
$requestedSource = new PureSource();
|
||||
$requestedSource->setSlug(SystemSlugType::IMPRINT);
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setSource($requestedSource);
|
||||
$requestedRight->setLayer(LayerType::SOURCE);
|
||||
$requestedRight->setType(CRUDType::READ);
|
||||
$sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler());
|
||||
|
||||
return $sourceResponseManager->getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"PUT"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::update()
|
||||
*/
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/sources/.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"GET"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\APIControllerInterface::list()
|
||||
*/
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"DELETE"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::delete()
|
||||
*/
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
12
application/symfony/src/Controller/AbstractController.php
Normal file
12
application/symfony/src/Controller/AbstractController.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use FOS\RestBundle\Controller\FOSRestController;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractController extends FOSRestController
|
||||
{
|
||||
}
|
52
application/symfony/src/Controller/DefaultController.php
Normal file
52
application/symfony/src/Controller/DefaultController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Entity\Meta\Right;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Source\PureSource;
|
||||
use App\Domain\ResponseManagement\SourceRESTResponseManager;
|
||||
|
||||
/**
|
||||
* This controller offers the standart routes for the template.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class DefaultController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @todo Optimize function!
|
||||
* @Route("/imprint.{_format}", defaults={"_format"="json"}, name="imprint")
|
||||
*/
|
||||
public function imprint(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$requestedSource = new PureSource();
|
||||
$requestedSource->setSlug(SystemSlugType::IMPRINT);
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setSource($requestedSource);
|
||||
$requestedRight->setLayer(LayerType::SOURCE);
|
||||
$requestedRight->setType(CRUDType::READ);
|
||||
$sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler());
|
||||
|
||||
return $sourceResponseManager->getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/", name="homepage")
|
||||
*/
|
||||
public function homepage(): Response
|
||||
{
|
||||
return $this->render('standard/homepage.html.twig');
|
||||
}
|
||||
|
||||
protected function setEntityName(): void
|
||||
{
|
||||
$this->entityName = AbstractSource::class;
|
||||
}
|
||||
}
|
22
application/symfony/src/Controller/HtmlController.php
Normal file
22
application/symfony/src/Controller/HtmlController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Offers an static webpage with bootstrap.
|
||||
*
|
||||
* @see https://getbootstrap.com/
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Write tests!
|
||||
*/
|
||||
final class HtmlController extends AbstractController
|
||||
{
|
||||
public function html(Request $request): Response
|
||||
{
|
||||
}
|
||||
}
|
23
application/symfony/src/Controller/SPAController.php
Normal file
23
application/symfony/src/Controller/SPAController.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Offers an SPA with Vue.js.
|
||||
*
|
||||
* @see https://vuejs.org/
|
||||
* @see https://de.wikipedia.org/wiki/Single-Page-Webanwendung
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Write tests!
|
||||
*/
|
||||
class SPAController extends AbstractController
|
||||
{
|
||||
public function spa(Request $request): Response
|
||||
{
|
||||
}
|
||||
}
|
0
application/symfony/src/DBAL/Types/.gitignore
vendored
Normal file
0
application/symfony/src/DBAL/Types/.gitignore
vendored
Normal file
31
application/symfony/src/DBAL/Types/LanguageType.php
Normal file
31
application/symfony/src/DBAL/Types/LanguageType.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Containes all activated languages.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LanguageType extends AbstractEnumType
|
||||
{
|
||||
public const GERMAN = 'de';
|
||||
|
||||
public const ENGLISH = 'en';
|
||||
|
||||
public const DUTCH = 'nl';
|
||||
|
||||
public const SPANISH = 'es';
|
||||
|
||||
public const ESPERANTO = 'eo';
|
||||
|
||||
protected static $choices = [
|
||||
self::GERMAN => 'German',
|
||||
self::ENGLISH => 'English',
|
||||
self::SPANISH => 'Spanish',
|
||||
self::ESPERANTO => 'Esperanto',
|
||||
self::DUTCH => 'Dutch',
|
||||
];
|
||||
}
|
29
application/symfony/src/DBAL/Types/MenuEventType.php
Normal file
29
application/symfony/src/DBAL/Types/MenuEventType.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Not integrated in the db. Just used for mapping.
|
||||
* May it will be helpfull for tracking ;).
|
||||
*
|
||||
* @deprecated this class doesn't make sense here. Find an other place for it
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class MenuEventType extends AbstractEnumType
|
||||
{
|
||||
public const USER = 'app.menu.topbar.user';
|
||||
|
||||
public const SOURCE = 'app.menu.subbar.source';
|
||||
|
||||
public const NODE = 'app.menu.subbar.node';
|
||||
|
||||
/**
|
||||
* May this will be used in the future.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $choices = [];
|
||||
}
|
26
application/symfony/src/DBAL/Types/Meta/Right/CRUDType.php
Normal file
26
application/symfony/src/DBAL/Types/Meta/Right/CRUDType.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types\Meta\Right;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class CRUDType extends AbstractEnumType
|
||||
{
|
||||
public const CREATE = 'create';
|
||||
|
||||
public const READ = 'read';
|
||||
|
||||
public const UPDATE = 'update';
|
||||
|
||||
public const DELETE = 'delete';
|
||||
|
||||
protected static $choices = [
|
||||
self::CREATE => 'create',
|
||||
self::READ => 'read',
|
||||
self::UPDATE => 'update',
|
||||
self::DELETE => 'delete',
|
||||
];
|
||||
}
|
32
application/symfony/src/DBAL/Types/Meta/Right/LayerType.php
Normal file
32
application/symfony/src/DBAL/Types/Meta/Right/LayerType.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types\Meta\Right;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LayerType extends AbstractEnumType
|
||||
{
|
||||
public const HEREDITY = 'heredity';
|
||||
|
||||
public const RIGHT = 'right';
|
||||
|
||||
public const SOURCE = 'source';
|
||||
|
||||
public const LAW = 'law';
|
||||
|
||||
public const MEMBER = 'member';
|
||||
|
||||
/**
|
||||
* @var array Ordered by the importants of implementation
|
||||
*/
|
||||
protected static $choices = [
|
||||
self::SOURCE => 'source',
|
||||
self::LAW => 'law',
|
||||
self::RIGHT => 'right',
|
||||
self::MEMBER => 'member',
|
||||
self::HEREDITY => 'heredity',
|
||||
];
|
||||
}
|
25
application/symfony/src/DBAL/Types/RESTResponseType.php
Normal file
25
application/symfony/src/DBAL/Types/RESTResponseType.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Containes the template types which the system can process.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RESTResponseType extends AbstractEnumType
|
||||
{
|
||||
public const JSON = 'json';
|
||||
|
||||
public const HTML = 'html';
|
||||
|
||||
public const XML = 'xml';
|
||||
|
||||
protected static $choices = [
|
||||
self::JSON => 'json',
|
||||
self::HTML => 'html',
|
||||
self::XML => 'xml',
|
||||
];
|
||||
}
|
26
application/symfony/src/DBAL/Types/SystemSlugType.php
Normal file
26
application/symfony/src/DBAL/Types/SystemSlugType.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Containes the system slugs.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Organize this somehow on an other way
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
final class SystemSlugType extends AbstractEnumType
|
||||
{
|
||||
public const IMPRINT = 'IMPRINT';
|
||||
|
||||
public const GUEST_USER = 'GUEST_USER';
|
||||
|
||||
protected static $choices = [
|
||||
self::IMPRINT => 'imprint',
|
||||
self::GUEST_USER => 'guest user',
|
||||
];
|
||||
}
|
0
application/symfony/src/DataFixtures/.gitignore
vendored
Normal file
0
application/symfony/src/DataFixtures/.gitignore
vendored
Normal file
51
application/symfony/src/DataFixtures/DummyFixtures.php
Normal file
51
application/symfony/src/DataFixtures/DummyFixtures.php
Normal 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;
|
||||
}
|
||||
}
|
79
application/symfony/src/DataFixtures/SourceFixtures.php
Normal file
79
application/symfony/src/DataFixtures/SourceFixtures.php
Normal 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);
|
||||
}
|
||||
}
|
12
application/symfony/src/Domain/AbstractDomainService.php
Normal file
12
application/symfony/src/Domain/AbstractDomainService.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain;
|
||||
|
||||
/**
|
||||
* @deprecated Doesn't make sense!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractDomainService
|
||||
{
|
||||
}
|
63
application/symfony/src/Domain/FormManagement/FormMeta.php
Normal file
63
application/symfony/src/Domain/FormManagement/FormMeta.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use App\Domain\SourceManagement\SourceMetaInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMeta;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Optimize contructor parameter!
|
||||
*/
|
||||
class FormMeta implements FormMetaInterface
|
||||
{
|
||||
const FOLDER = 'form';
|
||||
|
||||
/**
|
||||
* @var SourceMetaInterface
|
||||
*/
|
||||
private $sourceMeta;
|
||||
|
||||
/**
|
||||
* @var TemplateMetaInterface
|
||||
*/
|
||||
private $templateMeta;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $formClass;
|
||||
|
||||
public function __construct(SourceMetaInterface $sourceMeta)
|
||||
{
|
||||
$this->sourceMeta = $sourceMeta;
|
||||
$this->setMeta();
|
||||
$this->setFormClass();
|
||||
}
|
||||
|
||||
private function setFormClass(): void
|
||||
{
|
||||
$this->formClass = 'App\\Form';
|
||||
foreach ($this->sourceMeta->getBasicPathArray() as $element) {
|
||||
$this->formClass .= '\\'.ucfirst($element);
|
||||
}
|
||||
$this->formClass .= '\\'.ucfirst($this->sourceMeta->getBasicName()).'Type';
|
||||
}
|
||||
|
||||
private function setMeta(): void
|
||||
{
|
||||
$this->templateMeta = new TemplateMeta($this->sourceMeta->getBasicPathArray(), $this->sourceMeta->getBasicName(), self::FOLDER);
|
||||
}
|
||||
|
||||
public function getFormClass(): string
|
||||
{
|
||||
return $this->formClass;
|
||||
}
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface
|
||||
{
|
||||
return $this->templateMeta;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
|
||||
interface FormMetaInterface
|
||||
{
|
||||
public function getFormClass(): string;
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface;
|
||||
}
|
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\LawManagement;
|
||||
|
||||
use PhpCollection\CollectionInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\LawInterface;
|
||||
use App\Domain\RightManagement\RightChecker;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\SourceManagement\SourceMemberInformation;
|
||||
|
||||
/**
|
||||
* @todo Implement checking by operation sources
|
||||
* @todo chek if recievers are still neccessary and if they should be implemented
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LawPermissionCheckerService implements LawPermissionCheckerServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var LawInterface
|
||||
*/
|
||||
private $law;
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param string $value
|
||||
* @param string $attribut
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getFilteredRights(Collection $rights, string $value, string $attribut): Collection
|
||||
{
|
||||
$result = new ArrayCollection();
|
||||
foreach ($rights as $right) {
|
||||
if ($right->{'get'.$attribut}() === $value) {
|
||||
$result->add($right);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param string $type
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByType(Collection $rights, string $type): Collection
|
||||
{
|
||||
return $this->getFilteredRights($rights, $type, 'Type');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param SourceInterface $reciever
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByReciever(Collection $rights, SourceInterface $reciever): Collection
|
||||
{
|
||||
$result = new ArrayCollection();
|
||||
foreach ($rights as $right) {
|
||||
if ($right->getReciever() === $reciever || $this->memberExist($right, $reciever)) {
|
||||
$result->add($right);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement!
|
||||
*
|
||||
* @param RightInterface $right
|
||||
* @param SourceInterface $recieverSource
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function memberExist(RightInterface $right, SourceInterface $recieverSource): bool
|
||||
{
|
||||
$rightMemberInformation = new SourceMemberInformation($right->getReciever());
|
||||
$rightMemberSources = $rightMemberInformation->getAllMembers();
|
||||
foreach ($rightMemberSources as $memberSource) {
|
||||
if ($memberSource === $recieverSource) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param string $layer
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByLayer(Collection $rights, string $layer): Collection
|
||||
{
|
||||
return $this->getFilteredRights($rights, $layer, 'Layer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo seems like this can be solved on a nicer way
|
||||
*
|
||||
* @param Collection|RightInterface[] $rights
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function sortByPriority(Collection $rights): Collection
|
||||
{
|
||||
$iterator = $rights->getIterator();
|
||||
$iterator->uasort(function ($first, $second) {
|
||||
return (int) $first->getPriority() > (int) $second->getPriority() ? 1 : -1;
|
||||
});
|
||||
$sorted = new ArrayCollection();
|
||||
foreach ($iterator as $right) {
|
||||
$sorted->add($right);
|
||||
}
|
||||
|
||||
return $sorted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CollectionInterface|RightInterface[] $rights
|
||||
* the rights which exist
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isGranted(Collection $rights, RightInterface $client): bool
|
||||
{
|
||||
if (0 === $rights->count()) {
|
||||
return $this->law->getGrant();
|
||||
}
|
||||
$right = $rights[0];
|
||||
$rightChecker = new RightChecker($right);
|
||||
|
||||
return $rightChecker->isGranted($client->getLayer(), $client->getType(), $client->getReciever());
|
||||
}
|
||||
|
||||
public function __construct(LawInterface $law)
|
||||
{
|
||||
$this->law = $law;
|
||||
}
|
||||
|
||||
public function hasPermission(RightInterface $clientRight): bool
|
||||
{
|
||||
$rights = clone $this->law->getRights();
|
||||
$rights = $this->getRightsByType($rights, $clientRight->getType());
|
||||
$rights = $this->getRightsByLayer($rights, $clientRight->getLayer());
|
||||
$rights = $this->getRightsByReciever($rights, $clientRight->getReciever());
|
||||
$rights = $this->sortByPriority($rights);
|
||||
|
||||
return $this->isGranted($rights, $clientRight);
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\LawManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
/**
|
||||
* Allows to check if a source has rights on a source.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LawPermissionCheckerServiceInterface
|
||||
{
|
||||
/**
|
||||
* Checks if the client has the right for executing.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPermission(RightInterface $clientRight): bool;
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\MemberManagement;
|
||||
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
final class MemberManager implements MemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var MemberRelationInterface
|
||||
*/
|
||||
private $memberRelation;
|
||||
|
||||
public function __construct(MemberRelationInterface $memberRelation)
|
||||
{
|
||||
$this->memberRelation = $memberRelation;
|
||||
}
|
||||
|
||||
public function addMember(MemberRelationInterface $member): void
|
||||
{
|
||||
if (!$this->memberRelation->getMembers()->contains($member)) {
|
||||
$this->memberRelation->getMembers()[] = $member;
|
||||
(new self($member))->addMembership($this->memberRelation);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeMember(MemberRelationInterface $member): void
|
||||
{
|
||||
if ($this->memberRelation->getMembers()->contains($member)) {
|
||||
$this->memberRelation->getMembers()->removeElement($member);
|
||||
(new self($member))->removeMembership($this->memberRelation);
|
||||
}
|
||||
}
|
||||
|
||||
public function addMembership(MemberRelationInterface $membership): void
|
||||
{
|
||||
if (!$this->memberRelation->getMemberships()->contains($membership)) {
|
||||
$this->memberRelation->getMemberships()[] = $membership;
|
||||
(new self($membership))->addMember($this->memberRelation);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeMembership(MemberRelationInterface $membership): void
|
||||
{
|
||||
if ($this->memberRelation->getMemberships()->contains($membership)) {
|
||||
$this->memberRelation->getMemberships()->removeElement($membership);
|
||||
(new self($membership))->removeMember($this->memberRelation);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\MemberManagement;
|
||||
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
interface MemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param MemberRelationInterface $member
|
||||
*/
|
||||
public function addMember(MemberRelationInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param MemberRelationInterface $member
|
||||
*/
|
||||
public function removeMember(MemberRelationInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param MemberRelationInterface $membership
|
||||
*/
|
||||
public function addMembership(MemberRelationInterface $membership): void;
|
||||
|
||||
/**
|
||||
* @param MemberRelationInterface $membership
|
||||
*/
|
||||
public function removeMembership(MemberRelationInterface $membership): void;
|
||||
}
|
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\ResponseManagement;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Entity\UserInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Domain\UserManagement\UserIdentityManager;
|
||||
use FOS\RestBundle\View\ViewHandlerInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\SecureLoadManagement\SecureSourceLoader;
|
||||
use FOS\RestBundle\View\View;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SourceRESTResponseManager implements SourceRESTResponseManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var UserInterface
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
private $requestedRight;
|
||||
|
||||
/**
|
||||
* @var ViewHandlerInterface
|
||||
*/
|
||||
private $viewHandler;
|
||||
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $loadedSource;
|
||||
|
||||
/**
|
||||
* @var View
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
* @param EntityManagerInterface $entityManager
|
||||
* @param RightInterface $requestedRight
|
||||
* @param ViewHandlerInterface $viewHandler
|
||||
*/
|
||||
public function __construct(?UserInterface $user, EntityManagerInterface $entityManager, RightInterface $requestedRight, ViewHandlerInterface $viewHandler)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->viewHandler = $viewHandler;
|
||||
$this->setUser($user);
|
||||
$this->setRequestedRight($requestedRight);
|
||||
$this->setLoadedSource();
|
||||
$this->setView();
|
||||
}
|
||||
|
||||
protected function setView(): void
|
||||
{
|
||||
$this->view = new View($this->loadedSource, 200);
|
||||
}
|
||||
|
||||
private function setLoadedSource(): void
|
||||
{
|
||||
$secureSourceLoader = new SecureSourceLoader($this->entityManager, $this->requestedRight);
|
||||
$this->loadedSource = $secureSourceLoader->getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
private function setUser(?UserInterface $user): void
|
||||
{
|
||||
$userIdentityManager = new UserIdentityManager($this->entityManager, $user);
|
||||
$this->user = $userIdentityManager->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @throws AllreadyDefinedException
|
||||
*/
|
||||
private function setRequestedRight(RightInterface $requestedRight): void
|
||||
{
|
||||
try {
|
||||
$requestedRight->getReciever();
|
||||
throw new AllreadyDefinedException('The reciever is allready defined.');
|
||||
} catch (\TypeError $error) {
|
||||
$requestedRight->setReciever($this->user->getSource());
|
||||
$this->requestedRight = $requestedRight;
|
||||
}
|
||||
}
|
||||
|
||||
public function getResponse(): Response
|
||||
{
|
||||
return $this->viewHandler->handle($this->view);
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\ResponseManagement;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
interface SourceRESTResponseManagerInterface
|
||||
{
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function getResponse(): Response;
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RightManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\SourceManagement\SourceMemberInformation;
|
||||
|
||||
/**
|
||||
* @todo Implement the check of conditions!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RightChecker implements RightCheckerInterface
|
||||
{
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
private $right;
|
||||
|
||||
/**
|
||||
* @todo Implement a performant solution
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
private function getAllSourcesToWhichRightApplies(): Collection
|
||||
{
|
||||
$rightSourceMemberInformation = new SourceMemberInformation($this->right->getReciever());
|
||||
$allSourcesToWhichRightApplies = clone $rightSourceMemberInformation->getAllMembers();
|
||||
$allSourcesToWhichRightApplies->add($this->right->getReciever());
|
||||
|
||||
return $allSourcesToWhichRightApplies;
|
||||
}
|
||||
|
||||
private function hasClientSource(SourceInterface $clientSource): bool
|
||||
{
|
||||
return $this->getAllSourcesToWhichRightApplies()->contains($clientSource);
|
||||
}
|
||||
|
||||
private function isLayerEqual(string $layer): bool
|
||||
{
|
||||
return $this->right->getLayer() === $layer;
|
||||
}
|
||||
|
||||
private function isTypeEqual(string $type): bool
|
||||
{
|
||||
return $this->right->getType() === $type;
|
||||
}
|
||||
|
||||
private function checkPermission(): bool
|
||||
{
|
||||
return $this->right->getGrant();
|
||||
}
|
||||
|
||||
public function __construct(RightInterface $right)
|
||||
{
|
||||
$this->right = $right;
|
||||
}
|
||||
|
||||
public function isGranted(string $layer, string $type, SourceInterface $source): bool
|
||||
{
|
||||
return $this->isLayerEqual($layer) && $this->isTypeEqual($type) && $this->hasClientSource($source) && $this->checkPermission();
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RightManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface RightCheckerInterface
|
||||
{
|
||||
public function isGranted(string $layer, string $type, SourceInterface $source): bool;
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureLoadManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use App\Domain\SecureManagement\SecureSourceChecker;
|
||||
use App\Exception\SourceAccessDenied;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureSourceLoader implements SecureSourceLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @todo It would be better to specify the type
|
||||
*
|
||||
* @var ObjectRepository
|
||||
*/
|
||||
private $sourceRepository;
|
||||
|
||||
/**
|
||||
* The source attribute of the right needs a slug OR id.
|
||||
*
|
||||
* @var RightInterface the right which is requested
|
||||
*/
|
||||
private $requestedRight;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*
|
||||
* @return RightInterface
|
||||
*/
|
||||
private function getClonedRightWithModifiedSource(SourceInterface $source): RightInterface
|
||||
{
|
||||
$requestedRight = clone $this->requestedRight;
|
||||
$requestedRight->setSource($source);
|
||||
|
||||
return $requestedRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SourceInterface
|
||||
*/
|
||||
private function loadSource(): SourceInterface
|
||||
{
|
||||
try {
|
||||
return $this->sourceRepository->find($this->requestedRight->getSource()->getId());
|
||||
} catch (\Error $error) {
|
||||
return $this->sourceRepository->findOneBySlug($this->requestedRight->getSource()->getSlug());
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager, RightInterface $requestedRight)
|
||||
{
|
||||
$this->sourceRepository = $entityManager->getRepository(AbstractSource::class);
|
||||
$this->requestedRight = $requestedRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureLoadManagement\SecureSourceLoaderInterface::getSource()
|
||||
*/
|
||||
public function getSource(): SourceInterface
|
||||
{
|
||||
$source = $this->loadSource();
|
||||
$requestedRight = $this->getClonedRightWithModifiedSource($source);
|
||||
$secureSourceChecker = new SecureSourceChecker($source);
|
||||
if ($secureSourceChecker->hasPermission($requestedRight)) {
|
||||
return $source;
|
||||
}
|
||||
throw new SourceAccessDenied();
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureLoadManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureSourceLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @throws AccessDeniedHttpException
|
||||
*
|
||||
* @return SourceInterface
|
||||
*/
|
||||
public function getSource(): SourceInterface;
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\LawManagement\LawPermissionCheckerService;
|
||||
use App\Exception\SourceAccessDenied;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureSourceChecker implements SecureSourceCheckerInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*/
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $methodName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isGetter(string $methodName): bool
|
||||
{
|
||||
return 'get' === substr($methodName, 0, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isSource($value): bool
|
||||
{
|
||||
return $value instanceof SourceInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $methodName
|
||||
*
|
||||
* @return SourceInterface|null
|
||||
*/
|
||||
private function getExpectedSource(string $methodName): ?SourceInterface
|
||||
{
|
||||
try {
|
||||
return $this->source->{$methodName}();
|
||||
} catch (\TypeError $typeError) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @throws SourceAccessDenied It's important to fire this exception to reduce complexity in debuging
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function itterateOverSourceAttributs(RightInterface $requestedRight): bool
|
||||
{
|
||||
foreach (get_class_methods($this->source) as $methodName) {
|
||||
if ($this->isGetter($methodName)) {
|
||||
$attributExpectedSource = $this->getExpectedSource($methodName);
|
||||
if ($attributExpectedSource) {
|
||||
$requestedSubSourceRight = clone $requestedRight;
|
||||
$requestedSubSourceRight->setSource($attributExpectedSource);
|
||||
if ($this->isSource($attributExpectedSource)) {
|
||||
$methodSecureSourceChecker = new self($attributExpectedSource);
|
||||
if (!$methodSecureSourceChecker->hasPermission($requestedSubSourceRight)) {
|
||||
throw new SourceAccessDenied('Access denied for subsource!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureManagement\SecureSourceCheckerInterface::hasPermission()
|
||||
*/
|
||||
public function hasPermission(RightInterface $requestedRight): bool
|
||||
{
|
||||
$law = new LawPermissionCheckerService($this->source->getLaw());
|
||||
|
||||
return $law->hasPermission($requestedRight) && $this->itterateOverSourceAttributs($requestedRight);
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Exception\SourceAccessDenied;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureSourceCheckerInterface
|
||||
{
|
||||
/**
|
||||
* @throws SourceAccessDenied
|
||||
*
|
||||
* @param RightInterface $right
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPermission(RightInterface $requestedRight): bool;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Domain\AbstractDomainService;
|
||||
|
||||
abstract class AbstractSourceService extends AbstractDomainService
|
||||
{
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
final class SourceMemberInformation implements SourceMemberInformationInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var Collection|SourceInterface[]
|
||||
*/
|
||||
private $members;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $members
|
||||
*/
|
||||
private function itterateOverMembers(Collection $members): void
|
||||
{
|
||||
foreach ($members as $member) {
|
||||
if (!$this->members->contains($member->getSource())) {
|
||||
$this->members->add($member->getSource());
|
||||
$this->itterateOverMembers($member->getMembers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceMemberInformationInterface::getAllMembers()
|
||||
*/
|
||||
public function getAllMembers(): Collection
|
||||
{
|
||||
$this->members = new ArrayCollection();
|
||||
$this->itterateOverMembers($this->source->getMemberRelation()->getMembers());
|
||||
|
||||
return $this->members;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMemberInformationInterface
|
||||
{
|
||||
/**
|
||||
* @return Collection|SourceInterface[] All Members which belong to a source
|
||||
*/
|
||||
public function getAllMembers(): Collection;
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\MemberManagement\MemberManagerInterface;
|
||||
use App\Domain\MemberManagement\MemberManager;
|
||||
|
||||
final class SourceMemberManager implements SourceMemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var MemberManagerInterface
|
||||
*/
|
||||
private $memberManager;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->memberManager = new MemberManager($this->source->getMemberRelation());
|
||||
}
|
||||
|
||||
public function addMember(SourceInterface $member): void
|
||||
{
|
||||
$this->memberManager->addMember($member->getMemberRelation());
|
||||
}
|
||||
|
||||
public function removeMember(SourceInterface $member): void
|
||||
{
|
||||
$this->memberManager->removeMember($member->getMemberRelation());
|
||||
}
|
||||
|
||||
public function addMembership(SourceInterface $membership): void
|
||||
{
|
||||
$this->memberManager->addMembership($membership->getMemberRelation());
|
||||
}
|
||||
|
||||
public function removeMembership(SourceInterface $membership): void
|
||||
{
|
||||
$this->memberManager->removeMembership($membership->getMemberRelation());
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param SourceInterface $member
|
||||
*/
|
||||
public function addMember(SourceInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $member
|
||||
*/
|
||||
public function removeMember(SourceInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $membership
|
||||
*/
|
||||
public function addMembership(SourceInterface $membership): void;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $membership
|
||||
*/
|
||||
public function removeMembership(SourceInterface $membership): void;
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
final class SourceMembershipInformation implements SourceMembershipInformationInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var Collection|SourceInterface[]
|
||||
*/
|
||||
private $memberships;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $memberships
|
||||
*/
|
||||
private function itterateOverMemberships(Collection $memberships): void
|
||||
{
|
||||
foreach ($memberships as $membership) {
|
||||
if (!$this->memberships->contains($membership->getSource())) {
|
||||
$this->memberships->add($membership->getSource());
|
||||
$this->itterateOverMemberships($membership->getMemberships());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceMembershipInformationInterface::getAllMemberships()
|
||||
*/
|
||||
public function getAllMemberships(): Collection
|
||||
{
|
||||
$this->memberships = new ArrayCollection();
|
||||
$this->itterateOverMemberships($this->source->getMemberRelation()->getMemberships());
|
||||
|
||||
return $this->memberships;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMembershipInformationInterface
|
||||
{
|
||||
/**
|
||||
* @return Collection|SourceInterface[] all Sources which a Source belongs to
|
||||
*/
|
||||
public function getAllMemberships(): Collection;
|
||||
}
|
126
application/symfony/src/Domain/SourceManagement/SourceMeta.php
Normal file
126
application/symfony/src/Domain/SourceManagement/SourceMeta.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Domain\FormManagement\FormMetaInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMeta;
|
||||
use App\Domain\FormManagement\FormMeta;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SourceMeta implements SourceMetaInterface
|
||||
{
|
||||
const FOLDER = 'entity';
|
||||
|
||||
/**
|
||||
* @var \ReflectionClass
|
||||
*/
|
||||
private $sourceReflection;
|
||||
|
||||
/**
|
||||
* @var \ReflectionClass
|
||||
*/
|
||||
private $interfaceReflection;
|
||||
|
||||
/**
|
||||
* @var TemplateMetaInterface
|
||||
*/
|
||||
private $templateMeta;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $basicPathArray;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basicName;
|
||||
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var FormMetaInterface
|
||||
*/
|
||||
private $formMeta;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->sourceReflection = new \ReflectionClass($source);
|
||||
$this->setBasicPathArray();
|
||||
$this->setBasicName();
|
||||
$this->setInterfaceReflection();
|
||||
$this->setTemplateMeta();
|
||||
$this->formMeta = new FormMeta($this);
|
||||
}
|
||||
|
||||
private function setTemplateMeta(): void
|
||||
{
|
||||
$this->templateMeta = new TemplateMeta($this->basicPathArray, $this->basicName, self::FOLDER);
|
||||
}
|
||||
|
||||
private function setBasicPathArray(): void
|
||||
{
|
||||
$namespace = $this->sourceReflection->getNamespaceName();
|
||||
$namespaceWithoutRoot = str_replace('App\\Entity\\', '', $namespace);
|
||||
$this->basicPathArray = [];
|
||||
foreach (explode('\\', $namespaceWithoutRoot) as $element) {
|
||||
$this->basicPathArray[] = strtolower($element);
|
||||
}
|
||||
}
|
||||
|
||||
private function setInterfaceReflection(): void
|
||||
{
|
||||
$namespace = str_replace('\Abstract', '\\', $this->sourceReflection->getName()).'Interface';
|
||||
$this->interfaceReflection = new \ReflectionClass($namespace);
|
||||
}
|
||||
|
||||
private function setBasicName(): void
|
||||
{
|
||||
$withoutAbstract = str_replace('Abstract', '', $this->sourceReflection->getShortName());
|
||||
$withoutSource = str_replace('Source', '', $withoutAbstract);
|
||||
$this->basicName = strtolower($withoutSource);
|
||||
}
|
||||
|
||||
public function getBasicPathArray(): array
|
||||
{
|
||||
return $this->basicPathArray;
|
||||
}
|
||||
|
||||
public function getInterfaceReflection(): \ReflectionClass
|
||||
{
|
||||
return $this->interfaceReflection;
|
||||
}
|
||||
|
||||
public function getSourceReflection(): \ReflectionClass
|
||||
{
|
||||
return $this->sourceReflection;
|
||||
}
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface
|
||||
{
|
||||
return $this->templateMeta;
|
||||
}
|
||||
|
||||
public function getBasicName(): string
|
||||
{
|
||||
return $this->basicName;
|
||||
}
|
||||
|
||||
public function getSource(): SourceInterface
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function getFormMeta(): FormMetaInterface
|
||||
{
|
||||
return $this->formMeta;
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\FormManagement\FormMetaInterface;
|
||||
|
||||
/**
|
||||
* A meta source offers informations, which the system needs to handle the source.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SourceMetaInterface
|
||||
{
|
||||
public function getSourceReflection(): \ReflectionClass;
|
||||
|
||||
public function getInterfaceReflection(): \ReflectionClass;
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface;
|
||||
|
||||
/**
|
||||
* @return array the namespace elements without the root
|
||||
*/
|
||||
public function getBasicPathArray(): array;
|
||||
|
||||
/**
|
||||
* @return string Short class name in lower case without "Abstract" and "Source"
|
||||
*/
|
||||
public function getBasicName(): string;
|
||||
|
||||
/**
|
||||
* @return SourceInterface The source to which the meta object belongs to
|
||||
*/
|
||||
public function getSource(): SourceInterface;
|
||||
|
||||
public function getFormMeta(): FormMetaInterface;
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Exception\AllreadySetException;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Entity\Meta\Law;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
use App\Exception\NotSetException;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SourceRightManager implements SourceRightManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*/
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws AllreadyDefinedException If the attribut is allready defined
|
||||
*/
|
||||
private function checkRightAttributes(RightInterface $right): void
|
||||
{
|
||||
$attributes = ['source', 'law'];
|
||||
foreach ($attributes as $attribut) {
|
||||
try {
|
||||
$right->{'get'.ucfirst($attribut)}();
|
||||
throw new AllreadyDefinedException("The attribut \"$attribut\" is allready defined!");
|
||||
} catch (\Error $error) {
|
||||
//Expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|RightInterface[]
|
||||
*/
|
||||
private function getRights(): ArrayCollection
|
||||
{
|
||||
return $this->source->getLaw()->getRights();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceRightManagerInterface::addRight()
|
||||
*/
|
||||
public function addRight(RightInterface $right): void
|
||||
{
|
||||
if ($this->getRights()->contains($right)) {
|
||||
throw new AllreadySetException('The right was allready added.');
|
||||
}
|
||||
$this->checkRightAttributes($right);
|
||||
$right->setSource($this->source);
|
||||
$right->setLaw($this->source->getLaw());
|
||||
$this->getRights()->add($right);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceRightManagerInterface::removeRight()
|
||||
*/
|
||||
public function removeRight(RightInterface $right): void
|
||||
{
|
||||
$right->setSource(new class() extends AbstractSource {
|
||||
});
|
||||
$right->setLaw(new Law());
|
||||
if (!$this->getRights()->removeElement($right)) {
|
||||
throw new NotSetException('The right to remove is not set.');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Exception\AllreadySetException;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
use App\Exception\NotSetException;
|
||||
|
||||
interface SourceRightManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param RightInterface $right
|
||||
*
|
||||
* @throws AllreadySetException
|
||||
* @throws AllreadyDefinedException
|
||||
*/
|
||||
public function addRight(RightInterface $right): void;
|
||||
|
||||
/**
|
||||
* @param RightInterface $right
|
||||
*
|
||||
* @throws NotSetException
|
||||
*/
|
||||
public function removeRight(RightInterface $right): void;
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Source\Complex\Collection\TreeCollectionSourceInterface;
|
||||
use App\Entity\Source\Complex\Collection\TreeCollectionSource;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* Allows to iterate over a tree.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Maybe lazy loading would be helpfull for performance
|
||||
*/
|
||||
final class TreeSourceService extends AbstractSourceService implements TreeSourceServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var TreeCollectionSourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* Containes all branches of the actual level of the tree.
|
||||
*
|
||||
* @var Collection
|
||||
*/
|
||||
private $branches;
|
||||
|
||||
/**
|
||||
* Containes all leaves of the actual level of the tree.
|
||||
*
|
||||
* @var Collection
|
||||
*/
|
||||
private $leaves;
|
||||
|
||||
public function __construct(TreeCollectionSource $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->branches = new ArrayCollection();
|
||||
$this->leaves = new ArrayCollection();
|
||||
$this->basicSort();
|
||||
}
|
||||
|
||||
private function sortMember(SourceInterface $member): bool
|
||||
{
|
||||
if ($member instanceof TreeCollectionSource) {
|
||||
return $this->branches->add($member);
|
||||
}
|
||||
|
||||
return $this->leaves->add($member);
|
||||
}
|
||||
|
||||
private function basicSort(): void
|
||||
{
|
||||
foreach ($this->source->getCollection() as $member) {
|
||||
$this->sortMember($member);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBranches(): Collection
|
||||
{
|
||||
return $this->branches;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Remove the optional parameter and put the logic in a private funtion.
|
||||
* @todo Remove the getAllBranches use inside the function.
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\TreeSourceServiceInterface::getAllBranches()
|
||||
*/
|
||||
public function getAllBranches(): Collection
|
||||
{
|
||||
$allBranches = new ArrayCollection($this->branches->toArray());
|
||||
foreach ($this->branches->toArray() as $branch) {
|
||||
$this->itterateOverBranch($branch, $allBranches);
|
||||
}
|
||||
|
||||
return $allBranches;
|
||||
}
|
||||
|
||||
private function itterateOverBranch(TreeCollectionSourceInterface $branch, ArrayCollection $allBranches): void
|
||||
{
|
||||
foreach ((new self($branch))->getBranches() as $branchBranch) {
|
||||
if (!$allBranches->contains($branchBranch)) {
|
||||
$allBranches->add($branchBranch);
|
||||
if ($branchBranch instanceof TreeCollectionSourceInterface) {
|
||||
$this->itterateOverBranch($branchBranch, $allBranches);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getLeaves(): Collection
|
||||
{
|
||||
return $this->leaves;
|
||||
}
|
||||
|
||||
public function getAllLeaves(): Collection
|
||||
{
|
||||
$leaves = new ArrayCollection($this->getLeaves()->toArray());
|
||||
foreach ($this->getAllBranches() as $branch) {
|
||||
foreach ((new self($branch))->getLeaves() as $leave) {
|
||||
if (!$leaves->contains($leave)) {
|
||||
$leaves->add($leave);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $leaves;
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
interface TreeSourceServiceInterface
|
||||
{
|
||||
/**
|
||||
* Delivers the branches of the actual tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBranches(): Collection;
|
||||
|
||||
/**
|
||||
* Delivers the members of the actual tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getLeaves(): Collection;
|
||||
|
||||
/**
|
||||
* Delivers all members till a infinite level of the tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllLeaves(): Collection;
|
||||
|
||||
/**
|
||||
* Delivers all branches till a infinite level of the actual tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllBranches(): Collection;
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
use App\DBAL\Types\RESTResponseType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class TemplateMeta implements TemplateMetaInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $basicPathArray;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basicName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type = RESTResponseType::HTML;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pathSuffix;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $frameTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $folder;
|
||||
|
||||
public function __construct(array $basicPathArray, string $basicName, string $folder)
|
||||
{
|
||||
$this->basicPathArray = $basicPathArray;
|
||||
$this->basicName = $basicName;
|
||||
$this->folder = $folder;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
private function init()
|
||||
{
|
||||
$this->setPathSuffix();
|
||||
$this->setFrameTemplatePath();
|
||||
$this->setContentTemplatePath();
|
||||
}
|
||||
|
||||
private function setPathSuffix(): void
|
||||
{
|
||||
$this->pathSuffix = $this->folder.'/'.implode('/', $this->basicPathArray).'/'.$this->basicName.'.'.$this->type.'.twig';
|
||||
}
|
||||
|
||||
private function setFrameTemplatePath(): void
|
||||
{
|
||||
$this->frameTemplatePath = 'frame/'.$this->pathSuffix;
|
||||
}
|
||||
|
||||
private function setContentTemplatePath(): void
|
||||
{
|
||||
$this->contentTemplatePath = 'content/'.$this->pathSuffix;
|
||||
}
|
||||
|
||||
public function getFrameTemplatePath(): string
|
||||
{
|
||||
return $this->frameTemplatePath;
|
||||
}
|
||||
|
||||
public function getContentTemplatePath(): string
|
||||
{
|
||||
return $this->contentTemplatePath;
|
||||
}
|
||||
|
||||
public function setTemplateType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function getTemplateType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
/**
|
||||
* Manages all informations which are needed to process templates.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface TemplateMetaInterface
|
||||
{
|
||||
/**
|
||||
* Sets the template type which should be processed(General html);.
|
||||
*/
|
||||
public function setTemplateType(string $type): void;
|
||||
|
||||
public function getTemplateType(): string;
|
||||
|
||||
/**
|
||||
* Returns a template inclusiv frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFrameTemplatePath(): string;
|
||||
|
||||
/**
|
||||
* Returns a template without a frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContentTemplatePath(): string;
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\UserManagement;
|
||||
|
||||
use App\Entity\UserInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Repository\Source\SourceRepository;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class UserIdentityManager implements UserIdentityManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var UserInterface
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var SourceRepository
|
||||
*/
|
||||
private $sourceRepository;
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $entityManager
|
||||
*/
|
||||
private function setSourceRepository(EntityManagerInterface $entityManager): void
|
||||
{
|
||||
$this->sourceRepository = $entityManager->getRepository(AbstractSource::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
private function setUser(?UserInterface $user): void
|
||||
{
|
||||
if ($user) {
|
||||
$this->user = $user;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->user = new User();
|
||||
$this->user->setSource($this->sourceRepository->findOneBySlug(SystemSlugType::GUEST_USER));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $entityManager
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entityManager, ?UserInterface $user)
|
||||
{
|
||||
$this->setSourceRepository($entityManager);
|
||||
$this->setUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\UserManagement\UserIdentityManagerInterface::getUser()
|
||||
*/
|
||||
public function getUser(): UserInterface
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\UserManagement;
|
||||
|
||||
use App\Entity\UserInterface;
|
||||
|
||||
interface UserIdentityManagerInterface
|
||||
{
|
||||
/**
|
||||
* @return UserInterface
|
||||
*/
|
||||
public function getUser(): UserInterface;
|
||||
}
|
0
application/symfony/src/Entity/.gitignore
vendored
Normal file
0
application/symfony/src/Entity/.gitignore
vendored
Normal file
41
application/symfony/src/Entity/AbstractEntity.php
Normal file
41
application/symfony/src/Entity/AbstractEntity.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Attribut\IdAttribut;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\VersionAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractEntity implements EntityInterface
|
||||
{
|
||||
use IdAttribut, VersionAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")(strategy="AUTO")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @version @ORM\Column(type="integer")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->version = 0;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return __CLASS__.':'.spl_object_hash($this);
|
||||
}
|
||||
}
|
26
application/symfony/src/Entity/Attribut/ChildsAttribut.php
Normal file
26
application/symfony/src/Entity/Attribut/ChildsAttribut.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait ChildsAttribut
|
||||
{
|
||||
/**
|
||||
* @var Collection|ChildsAttributeInterface[]
|
||||
*/
|
||||
protected $childs;
|
||||
|
||||
public function getChilds(): Collection
|
||||
{
|
||||
return $this->childs;
|
||||
}
|
||||
|
||||
public function setChilds(Collection $childs): void
|
||||
{
|
||||
$this->childs = $childs;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ChildsAttributeInterface
|
||||
{
|
||||
public function setChilds(Collection $childs): void;
|
||||
|
||||
public function getChilds(): Collection;
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
trait CollectionAttribut
|
||||
{
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getCollection(): Collection
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function setCollection(Collection $collection): void
|
||||
{
|
||||
$this->collection = $collection;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
interface CollectionAttributInterface
|
||||
{
|
||||
public function getCollection(): Collection;
|
||||
|
||||
public function setCollection(Collection $collection): void;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Logic\Operation\OperationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait ConditionAttribut
|
||||
{
|
||||
/**
|
||||
* @var OperationInterface
|
||||
*/
|
||||
protected $condition;
|
||||
|
||||
public function getCondition(): OperationInterface
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
public function setCondition(OperationInterface $condition): void
|
||||
{
|
||||
$this->condition = $condition;
|
||||
}
|
||||
|
||||
public function hasCondition(): bool
|
||||
{
|
||||
return $this->condition instanceof OperationInterface;
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Logic\Operation\OperationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ConditionAttributInterface
|
||||
{
|
||||
public function getCondition(): OperationInterface;
|
||||
|
||||
public function setCondition(OperationInterface $operation): void;
|
||||
|
||||
public function hasCondition(): bool;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\Parent\CreatorRelationInterface;
|
||||
|
||||
trait CreatorRelationAttribut
|
||||
{
|
||||
/**
|
||||
* @var CreatorRelationInterface
|
||||
*/
|
||||
protected $creatorRelation;
|
||||
|
||||
public function setCreatorRelation(CreatorRelationInterface $creatorRelation)
|
||||
{
|
||||
$this->creatorRelation = $creatorRelation;
|
||||
}
|
||||
|
||||
public function getCreatorRelation(): CreatorRelationInterface
|
||||
{
|
||||
return $this->creatorRelation;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\Parent\CreatorRelationInterface;
|
||||
|
||||
interface CreatorRelationAttributInterface
|
||||
{
|
||||
public function setCreatorRelation(CreatorRelationInterface $creatorRelation);
|
||||
|
||||
public function getCreatorRelation(): CreatorRelationInterface;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Primitive\Name\FirstNameSourceInterface;
|
||||
|
||||
trait FirstNameSourceAttribut
|
||||
{
|
||||
/**
|
||||
* @var FirstNameSourceInterface
|
||||
*/
|
||||
protected $firstNameSource;
|
||||
|
||||
public function getFirstNameSource(): FirstNameSourceInterface
|
||||
{
|
||||
return $this->firstNameSource;
|
||||
}
|
||||
|
||||
public function setFirstNameSource(FirstNameSourceInterface $name): void
|
||||
{
|
||||
$this->firstNameSource = $name;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Primitive\Name\FirstNameSourceInterface;
|
||||
|
||||
interface FirstNameSourceAttributInterface
|
||||
{
|
||||
public function getFirstNameSource(): FirstNameSourceInterface;
|
||||
|
||||
public function setFirstNameSource(FirstNameSourceInterface $name): void;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Complex\FullPersonNameSourceInterface;
|
||||
|
||||
trait FullPersonNameSourceAttribut
|
||||
{
|
||||
/**
|
||||
* @var FullPersonNameSourceInterface
|
||||
*/
|
||||
protected $fullPersonNameSource;
|
||||
|
||||
public function getFullPersonNameSource(): FullPersonNameSourceInterface
|
||||
{
|
||||
return $this->fullPersonNameSource;
|
||||
}
|
||||
|
||||
public function setFullPersonNameSource(FullPersonNameSourceInterface $fullname): void
|
||||
{
|
||||
$this->fullPersonNameSource = $fullname;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Complex\FullPersonNameSourceInterface;
|
||||
|
||||
interface FullPersonNameSourceAttributInterface
|
||||
{
|
||||
public function getFullPersonNameSource(): FullPersonNameSourceInterface;
|
||||
|
||||
public function setFullPersonNameSource(FullPersonNameSourceInterface $fullname): void;
|
||||
}
|
24
application/symfony/src/Entity/Attribut/GrantAttribut.php
Normal file
24
application/symfony/src/Entity/Attribut/GrantAttribut.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait GrantAttribut
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $grant;
|
||||
|
||||
public function setGrant(bool $grant): void
|
||||
{
|
||||
$this->grant = $grant;
|
||||
}
|
||||
|
||||
public function getGrant(): bool
|
||||
{
|
||||
return $this->grant;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface GrantAttributInterface
|
||||
{
|
||||
public function setGrant(bool $grant): void;
|
||||
|
||||
public function getGrant(): bool;
|
||||
}
|
24
application/symfony/src/Entity/Attribut/IdAttribut.php
Normal file
24
application/symfony/src/Entity/Attribut/IdAttribut.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait IdAttribut
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
public function setId(int $id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface IdAttributInterface
|
||||
{
|
||||
public function setId(int $id): void;
|
||||
|
||||
public function getId(): int;
|
||||
}
|
26
application/symfony/src/Entity/Attribut/LawAttribut.php
Normal file
26
application/symfony/src/Entity/Attribut/LawAttribut.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\LawInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait LawAttribut
|
||||
{
|
||||
/**
|
||||
* @var LawInterface
|
||||
*/
|
||||
protected $law;
|
||||
|
||||
public function setLaw(LawInterface $law): void
|
||||
{
|
||||
$this->law = $law;
|
||||
}
|
||||
|
||||
public function getLaw(): LawInterface
|
||||
{
|
||||
return $this->law;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\LawInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LawAttributInterface
|
||||
{
|
||||
public function setLaw(LawInterface $law): void;
|
||||
|
||||
public function getLaw(): LawInterface;
|
||||
}
|
24
application/symfony/src/Entity/Attribut/LayerAttribut.php
Normal file
24
application/symfony/src/Entity/Attribut/LayerAttribut.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait LayerAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $layer;
|
||||
|
||||
public function setLayer(string $layer): void
|
||||
{
|
||||
$this->layer = $layer;
|
||||
}
|
||||
|
||||
public function getLayer(): string
|
||||
{
|
||||
return $this->layer;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LayerAttributInterface
|
||||
{
|
||||
public function setLayer(string $layer): void;
|
||||
|
||||
public function getLayer(): string;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
trait MemberRelationAttribut
|
||||
{
|
||||
/**
|
||||
* @var MemberRelationInterface
|
||||
*/
|
||||
protected $memberRelation;
|
||||
|
||||
public function setMemberRelation(MemberRelationInterface $memberRelation): void
|
||||
{
|
||||
$this->memberRelation = $memberRelation;
|
||||
}
|
||||
|
||||
public function getMemberRelation(): MemberRelationInterface
|
||||
{
|
||||
return $this->memberRelation;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
interface MemberRelationAttributInterface
|
||||
{
|
||||
public function setMemberRelation(MemberRelationInterface $memberRelation): void;
|
||||
|
||||
public function getMemberRelation(): MemberRelationInterface;
|
||||
}
|
33
application/symfony/src/Entity/Attribut/MembersAttribut.php
Normal file
33
application/symfony/src/Entity/Attribut/MembersAttribut.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait MembersAttribut
|
||||
{
|
||||
/**
|
||||
* @var Collection|MemberRelationInterface[]
|
||||
*/
|
||||
protected $members;
|
||||
|
||||
/**
|
||||
* @return Collection|MemberRelationInterface[]
|
||||
*/
|
||||
public function getMembers(): Collection
|
||||
{
|
||||
return $this->members;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $members
|
||||
*/
|
||||
public function setMembers(Collection $members): void
|
||||
{
|
||||
$this->members = $members;
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface MembersAttributInterface
|
||||
{
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $members
|
||||
*/
|
||||
public function setMembers(Collection $members): void;
|
||||
|
||||
/**
|
||||
* @return Collection|MemberRelationInterface[]
|
||||
*/
|
||||
public function getMembers(): Collection;
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait MembershipsAttribut
|
||||
{
|
||||
/**
|
||||
* @var Collection|MemberRelationInterface[]
|
||||
*/
|
||||
protected $memberships;
|
||||
|
||||
/**
|
||||
* @return Collection|MemberRelationInterface[]
|
||||
*/
|
||||
public function getMemberships(): Collection
|
||||
{
|
||||
return $this->memberships;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $memberships
|
||||
*/
|
||||
public function setMemberships(Collection $memberships): void
|
||||
{
|
||||
$this->memberships = $memberships;
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface MembershipsAttributInterface
|
||||
{
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $groups
|
||||
*/
|
||||
public function setMemberships(Collection $memberships): void;
|
||||
|
||||
/**
|
||||
* @return Collection|MemberRelationInterface[]
|
||||
*/
|
||||
public function getMemberships(): Collection;
|
||||
}
|
24
application/symfony/src/Entity/Attribut/NameAttribut.php
Normal file
24
application/symfony/src/Entity/Attribut/NameAttribut.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait NameAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface NameAttributInterface
|
||||
{
|
||||
public function setName(string $name): void;
|
||||
|
||||
public function getName(): string;
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Primitive\Name\NameSourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait NameSourceAttribut
|
||||
{
|
||||
/**
|
||||
* @var NameSourceInterface
|
||||
*/
|
||||
protected $nameSource;
|
||||
|
||||
public function setNameSource(NameSourceInterface $nameSource): void
|
||||
{
|
||||
$this->nameSource = $nameSource;
|
||||
}
|
||||
|
||||
public function getNameSource(): NameSourceInterface
|
||||
{
|
||||
return $this->nameSource;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Primitive\Name\NameSourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface NameSourceAttributInterface
|
||||
{
|
||||
public function setNameSource(NameSourceInterface $nameSource): void;
|
||||
|
||||
public function getNameSource(): NameSourceInterface;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\Parent\ParentRelationInterface;
|
||||
|
||||
trait ParentRelationAttribut
|
||||
{
|
||||
/**
|
||||
* @var ParentRelationInterface
|
||||
*/
|
||||
protected $parentRelation;
|
||||
|
||||
public function setParentRelation(ParentRelationInterface $parentRelation): void
|
||||
{
|
||||
$this->parentRelation = $parentRelation;
|
||||
}
|
||||
|
||||
public function getParentRelation(): ParentRelationInterface
|
||||
{
|
||||
return $this->parentRelation;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\Parent\ParentRelationInterface;
|
||||
|
||||
interface ParentRelationAttributInterface
|
||||
{
|
||||
public function setParentRelation(ParentRelationInterface $parentRelation): void;
|
||||
|
||||
public function getParentRelation(): ParentRelationInterface;
|
||||
}
|
26
application/symfony/src/Entity/Attribut/ParentsAttribut.php
Normal file
26
application/symfony/src/Entity/Attribut/ParentsAttribut.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait ParentsAttribut
|
||||
{
|
||||
/**
|
||||
* @var Collection|ParentsAttributInterface[]
|
||||
*/
|
||||
protected $parents;
|
||||
|
||||
public function getParents(): Collection
|
||||
{
|
||||
return $this->parents;
|
||||
}
|
||||
|
||||
public function setParents(Collection $parents): void
|
||||
{
|
||||
$this->parents = $parents;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ParentsAttributInterface
|
||||
{
|
||||
public function setParents(Collection $parents): void;
|
||||
|
||||
public function getParents(): Collection;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Complex\PersonIdentitySourceInterface;
|
||||
|
||||
trait PersonIdentitySourceAttribut
|
||||
{
|
||||
/**
|
||||
* @var PersonIdentitySourceInterface
|
||||
*/
|
||||
protected $personIdentitySource;
|
||||
|
||||
public function getPersonIdentitySource(): PersonIdentitySourceInterface
|
||||
{
|
||||
return $this->personIdentitySource;
|
||||
}
|
||||
|
||||
public function setPersonIdentitySource(PersonIdentitySourceInterface $identity): void
|
||||
{
|
||||
$this->personIdentitySource = $identity;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\Complex\PersonIdentitySourceInterface;
|
||||
|
||||
interface PersonIdentitySourceAttributInterface
|
||||
{
|
||||
public function getPersonIdentitySource(): PersonIdentitySourceInterface;
|
||||
|
||||
public function setPersonIdentitySource(PersonIdentitySourceInterface $identity): void;
|
||||
}
|
21
application/symfony/src/Entity/Attribut/PriorityAttribut.php
Normal file
21
application/symfony/src/Entity/Attribut/PriorityAttribut.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
trait PriorityAttribut
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $priority;
|
||||
|
||||
public function setPriority(int $priority): void
|
||||
{
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
public function getPriority(): int
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
interface PriorityAttributInterface
|
||||
{
|
||||
public function setPriority(int $priority): void;
|
||||
|
||||
public function getPriority(): int;
|
||||
}
|
26
application/symfony/src/Entity/Attribut/RecieverAttribut.php
Normal file
26
application/symfony/src/Entity/Attribut/RecieverAttribut.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RecieverAttribut
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
public function setReciever(SourceInterface $reciever): void
|
||||
{
|
||||
$this->reciever = $reciever;
|
||||
}
|
||||
|
||||
public function getReciever(): SourceInterface
|
||||
{
|
||||
return $this->reciever;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverAttributInterface
|
||||
{
|
||||
public function setReciever(SourceInterface $reciever): void;
|
||||
|
||||
public function getReciever(): SourceInterface;
|
||||
}
|
26
application/symfony/src/Entity/Attribut/RelationAttribut.php
Normal file
26
application/symfony/src/Entity/Attribut/RelationAttribut.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\RelationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RelationAttribut
|
||||
{
|
||||
/**
|
||||
* @var RelationInterface
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
public function setRelation(RelationInterface $relation): void
|
||||
{
|
||||
$this->relation = $relation;
|
||||
}
|
||||
|
||||
public function getRelation(): RelationInterface
|
||||
{
|
||||
return $this->relation;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\Relation\RelationInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RelationAttributInterface
|
||||
{
|
||||
public function setRelation(RelationInterface $relation): void;
|
||||
|
||||
public function getRelation(): RelationInterface;
|
||||
}
|
26
application/symfony/src/Entity/Attribut/RightAttribut.php
Normal file
26
application/symfony/src/Entity/Attribut/RightAttribut.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RightAttribut
|
||||
{
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
protected $right;
|
||||
|
||||
public function setRight(RightInterface $right): void
|
||||
{
|
||||
$this->right = $right;
|
||||
}
|
||||
|
||||
public function getRight(): RightInterface
|
||||
{
|
||||
return $this->right;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user