mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Applied CS fixer
This commit is contained in:
parent
91c41105c7
commit
6bc95f9729
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\EntityInterface;
|
use App\Entity\EntityInterface;
|
||||||
@ -6,9 +7,7 @@ use FOS\RestBundle\Controller\FOSRestController;
|
|||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
abstract class AbstractEntityController extends FOSRestController
|
abstract class AbstractEntityController extends FOSRestController
|
||||||
{
|
{
|
||||||
@ -16,13 +15,14 @@ abstract class AbstractEntityController extends FOSRestController
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $entityName;
|
protected $entityName;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct()
|
||||||
|
{
|
||||||
$this->setEntityName();
|
$this->setEntityName();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function setEntityName():void;
|
abstract protected function setEntityName(): void;
|
||||||
|
|
||||||
protected function loadEntityById(int $id): EntityInterface
|
protected function loadEntityById(int $id): EntityInterface
|
||||||
{
|
{
|
||||||
$entity = $this->getDoctrine()
|
$entity = $this->getDoctrine()
|
||||||
@ -31,13 +31,14 @@ abstract class AbstractEntityController extends FOSRestController
|
|||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('No entity found for id '.$id);
|
throw $this->createNotFoundException('No entity found for id '.$id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function redirectToRouteById(string $route, int $id): RedirectResponse
|
protected function redirectToRouteById(string $route, int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->redirectToRoute($route, [
|
return $this->redirectToRoute($route, [
|
||||||
'id' => $id
|
'id' => $id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use App\Entity\Meta\Law;
|
use App\Entity\Meta\Law;
|
||||||
use App\Entity\Meta\LawInterface;
|
use App\Entity\Meta\LawInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
|
*
|
||||||
* @todo Implement security!
|
* @todo Implement security!
|
||||||
*/
|
*/
|
||||||
class LawController extends AbstractEntityController
|
class LawController extends AbstractEntityController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @Route("/law/{id}.{_format}", defaults={"_format"="html"})
|
* @Route("/law/{id}.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function show(int $id): Response
|
public function show(int $id): Response
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
* @var LawInterface
|
||||||
* @var LawInterface $law
|
|
||||||
*/
|
*/
|
||||||
$law = $this->loadEntityById($id);
|
$law = $this->loadEntityById($id);
|
||||||
$view = $this->view($law, 200)
|
$view = $this->view($law, 200)
|
||||||
->setTemplate('law/view/standard.html.twig')
|
->setTemplate('law/view/standard.html.twig')
|
||||||
->setTemplateVar('law');
|
->setTemplateVar('law');
|
||||||
|
|
||||||
return $this->handleView($view);
|
return $this->handleView($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @Route("/law/{id}/right.{_format}", defaults={"_format"="html"})
|
* @Route("/law/{id}/right.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function right(int $id): RedirectResponse
|
public function right(int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement function!
|
* @todo Implement function!
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @Route("/law/{id}/node.{_format}", defaults={"_format"="html"})
|
* @Route("/law/{id}/node.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function node(int $id): RedirectResponse
|
public function node(int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement function!
|
* @todo Implement function!
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setEntityName(): void
|
protected function setEntityName(): void
|
||||||
{
|
{
|
||||||
$this->entityName = Law::class;
|
$this->entityName = Law::class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ use App\Entity\Meta\Relation;
|
|||||||
/**
|
/**
|
||||||
* @todo IMPLEMENT SECURITY!
|
* @todo IMPLEMENT SECURITY!
|
||||||
* @todo Refactor!
|
* @todo Refactor!
|
||||||
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
class NodeController extends AbstractEntityController
|
class NodeController extends AbstractEntityController
|
||||||
@ -22,42 +23,46 @@ class NodeController extends AbstractEntityController
|
|||||||
public function show(Request $request, int $id): Response
|
public function show(Request $request, int $id): Response
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var RelationInterface $node
|
* @var RelationInterface
|
||||||
*/
|
*/
|
||||||
$relation = $this->loadEntityById($id);
|
$relation = $this->loadEntityById($id);
|
||||||
$view = $this->view($relation, 200)
|
$view = $this->view($relation, 200)
|
||||||
->setTemplate('node/view/standard.html.twig')
|
->setTemplate('node/view/standard.html.twig')
|
||||||
->setTemplateVar('node');
|
->setTemplateVar('node');
|
||||||
|
|
||||||
return $this->handleView($view);
|
return $this->handleView($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/node/{id}/law.{_format}", defaults={"_format"="html"})
|
* @Route("/node/{id}/law.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function law(int $id): RedirectResponse
|
public function law(int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
$lawId = $this->loadEntityById($id)->getLaw()->getId();
|
$lawId = $this->loadEntityById($id)->getLaw()->getId();
|
||||||
return $this->redirectToRouteById('app_law_show',$lawId);
|
|
||||||
|
return $this->redirectToRouteById('app_law_show', $lawId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/node/{id}/parents.{_format}", defaults={"_format"="html"})
|
* @Route("/node/{id}/parents.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function parents(int $id):Response{
|
public function parents(int $id): Response
|
||||||
/**
|
{
|
||||||
|
/*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/node/{id}/childs.{_format}", defaults={"_format"="html"})
|
* @Route("/node/{id}/childs.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function childs(int $id):Response{
|
public function childs(int $id): Response
|
||||||
/**
|
{
|
||||||
|
/*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setEntityName(): void
|
protected function setEntityName(): void
|
||||||
{
|
{
|
||||||
$this->entityName = Relation::class;
|
$this->entityName = Relation::class;
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use App\Entity\Method;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use App\Creator\Factory\Template\Source\SourceTemplateFactory;
|
use App\Creator\Factory\Template\Source\SourceTemplateFactory;
|
||||||
use FOS\RestBundle\Controller\FOSRestController;
|
|
||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
use App\Creator\Factory\Template\Source\SourceTemplateFormFactory;
|
use App\Creator\Factory\Template\Source\SourceTemplateFormFactory;
|
||||||
use App\Creator\Factory\Form\Source\SourceFormFactory;
|
use App\Creator\Factory\Form\Source\SourceFormFactory;
|
||||||
@ -15,16 +14,13 @@ use App\Entity\Source\AbstractSource;
|
|||||||
use App\Entity\Meta\RelationInterface;
|
use App\Entity\Meta\RelationInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @todo IMPLEMENT SECURITY!
|
* @todo IMPLEMENT SECURITY!
|
||||||
*
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
class SourceController extends AbstractEntityController
|
class SourceController extends AbstractEntityController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @Route("/source/{id}.{_format}", defaults={"_format"="html"})
|
* @Route("/source/{id}.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function show(Request $request, int $id): Response
|
public function show(Request $request, int $id): Response
|
||||||
@ -35,12 +31,11 @@ class SourceController extends AbstractEntityController
|
|||||||
$view = $this->view($source, 200)
|
$view = $this->view($source, 200)
|
||||||
->setTemplate((new SourceTemplateFactory($source, $request))->getTemplatePath())
|
->setTemplate((new SourceTemplateFactory($source, $request))->getTemplatePath())
|
||||||
->setTemplateVar('source');
|
->setTemplateVar('source');
|
||||||
|
|
||||||
return $this->handleView($view);
|
return $this->handleView($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @Route("/source/{id}/edit.{_format}", defaults={"_format"="html"})
|
* @Route("/source/{id}/edit.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function edit(Request $request, int $id): Response
|
public function edit(Request $request, int $id): Response
|
||||||
@ -52,23 +47,24 @@ class SourceController extends AbstractEntityController
|
|||||||
$source = $form->getData();
|
$source = $form->getData();
|
||||||
$this->saveSource($source);
|
$this->saveSource($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render((new SourceTemplateFormFactory($source, $request))->getTemplatePath(), [
|
return $this->render((new SourceTemplateFormFactory($source, $request))->getTemplatePath(), [
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @Route("/source/{id}/node.{_format}", defaults={"_format"="html"})
|
* @Route("/source/{id}/node.{_format}", defaults={"_format"="html"})
|
||||||
*/
|
*/
|
||||||
public function node(int $id): RedirectResponse
|
public function node(int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
$nodeId = $this->loadNodeById($id)->getId();
|
$nodeId = $this->loadNodeById($id)->getId();
|
||||||
return $this->redirectToRouteById('app_node_show',$nodeId);
|
|
||||||
|
return $this->redirectToRouteById('app_node_show', $nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadNodeById(int $id):RelationInterface{
|
private function loadNodeById(int $id): RelationInterface
|
||||||
|
{
|
||||||
return $this->loadEntityById($id)->getNode();
|
return $this->loadEntityById($id)->getNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,20 +5,22 @@ namespace App\DBAL\Types;
|
|||||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not integrated in the db. Just used for mapping.
|
* Not integrated in the db. Just used for mapping.
|
||||||
* May it will be helpfull for tracking ;)
|
* May it will be helpfull for tracking ;).
|
||||||
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
final class MenuEventType extends AbstractEnumType
|
final class MenuEventType extends AbstractEnumType
|
||||||
{
|
{
|
||||||
public const USER = 'app.menu.topbar.user';
|
public const USER = 'app.menu.topbar.user';
|
||||||
|
|
||||||
public const SOURCE = 'app.menu.subbar.source';
|
public const SOURCE = 'app.menu.subbar.source';
|
||||||
|
|
||||||
public const NODE = 'app.menu.subbar.node';
|
public const NODE = 'app.menu.subbar.node';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* May this will be used in the future
|
* May this will be used in the future.
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $choices = [];
|
protected static $choices = [];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Entity\Attribut\IdAttribut;
|
use App\Entity\Attribut\IdAttribut;
|
||||||
@ -6,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use App\Entity\Attribut\VersionAttribut;
|
use App\Entity\Attribut\VersionAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
abstract class AbstractEntity implements EntityInterface
|
abstract class AbstractEntity implements EntityInterface
|
||||||
@ -14,7 +14,6 @@ abstract class AbstractEntity implements EntityInterface
|
|||||||
use IdAttribut, VersionAttribut;
|
use IdAttribut, VersionAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @ORM\Id()
|
* @ORM\Id()
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")(strategy="AUTO")
|
* @ORM\Column(type="integer")(strategy="AUTO")
|
||||||
@ -24,8 +23,8 @@ abstract class AbstractEntity implements EntityInterface
|
|||||||
protected $id;
|
protected $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @version @ORM\Column(type="integer")
|
* @version @ORM\Column(type="integer")
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $version;
|
protected $version;
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait VersionAttribut
|
trait VersionAttribut
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $version;
|
protected $version;
|
||||||
|
|
||||||
public function setVersion(int $version):void{
|
public function setVersion(int $version): void
|
||||||
|
{
|
||||||
$this->version = $version;
|
$this->version = $version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVersion():int{
|
public function getVersion(): int
|
||||||
|
{
|
||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entities which implement this interface can lock stuff on an optimistic base.
|
* Entities which implement this interface can lock stuff on an optimistic base.
|
||||||
|
*
|
||||||
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/transactions-and-concurrency.html
|
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/transactions-and-concurrency.html
|
||||||
* @see https://en.wikipedia.org/wiki/Optimistic_concurrency_control
|
* @see https://en.wikipedia.org/wiki/Optimistic_concurrency_control
|
||||||
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface VersionAttributInterface
|
interface VersionAttributInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns the revision version of the entity
|
* Returns the revision version of the entity.
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getVersion():int;
|
public function getVersion(): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the revision version of the entity
|
* Sets the revision version of the entity.
|
||||||
|
*
|
||||||
* @param int $version
|
* @param int $version
|
||||||
*/
|
*/
|
||||||
public function setVersion(int $version):void;
|
public function setVersion(int $version): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Entity\Attribut\VersionAttributInterface;
|
use App\Entity\Attribut\VersionAttributInterface;
|
||||||
use App\Entity\Attribut\IdAttributInterface;
|
use App\Entity\Attribut\IdAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface EntityInterface extends VersionAttributInterface, IdAttributInterface
|
interface EntityInterface extends VersionAttributInterface, IdAttributInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Meta;
|
namespace App\Entity\Meta;
|
||||||
|
|
||||||
use App\Entity\AbstractEntity;
|
use App\Entity\AbstractEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
abstract class AbstractMeta extends AbstractEntity implements MetaInterface
|
abstract class AbstractMeta extends AbstractEntity implements MetaInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Meta;
|
namespace App\Entity\Meta;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
@ -7,7 +8,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
use App\Entity\Attribut\RelationAttribut;
|
use App\Entity\Attribut\RelationAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
* @ORM\Table(name="meta_law")
|
* @ORM\Table(name="meta_law")
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
|
||||||
@ -17,7 +17,6 @@ final class Law extends AbstractMeta implements LawInterface
|
|||||||
use RightsAttribute, RelationAttribut;
|
use RightsAttribute, RelationAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @ORM\OneToMany(targetEntity="Right", mappedBy="law", cascade={"persist", "remove"})
|
* @ORM\OneToMany(targetEntity="Right", mappedBy="law", cascade={"persist", "remove"})
|
||||||
*
|
*
|
||||||
* @var ArrayCollection | Right[]
|
* @var ArrayCollection | Right[]
|
||||||
@ -36,7 +35,7 @@ final class Law extends AbstractMeta implements LawInterface
|
|||||||
|
|
||||||
public function isGranted(RelationInterface $relation, string $layer, string $right): bool
|
public function isGranted(RelationInterface $relation, string $layer, string $right): bool
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @var RightInterface
|
* @var RightInterface
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace App\Entity\Meta;
|
namespace App\Entity\Meta;
|
||||||
|
|
||||||
use App\Entity\Attribut\RightsAttributInterface;
|
use App\Entity\Attribut\RightsAttributInterface;
|
||||||
use App\Entity\Attribut\RelationAttributInterface;
|
|
||||||
use App\Entity\Method\RelationGrantedInterface;
|
use App\Entity\Method\RelationGrantedInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Meta;
|
namespace App\Entity\Meta;
|
||||||
|
|
||||||
use App\Entity\EntityInterface;
|
use App\Entity\EntityInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta entities contain informations which describe sources.
|
* Meta entities contain informations which describe sources.
|
||||||
* If you refer from a meta entity to an source be aware to catch infinite loops!
|
* If you refer from a meta entity to an source be aware to catch infinite loops!
|
||||||
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface MetaInterface extends EntityInterface
|
interface MetaInterface extends EntityInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use App\Entity\Attribut\RelationAttributInterface;
|
|||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface RecieverGroupInterface extends RelationAttributInterface, RecieverAttributInterface,MetaInterface
|
interface RecieverGroupInterface extends RelationAttributInterface, RecieverAttributInterface, MetaInterface
|
||||||
{
|
{
|
||||||
public function getAllRecievers(): ArrayCollection;
|
public function getAllRecievers(): ArrayCollection;
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,12 @@ use App\Entity\Source\SourceInterface;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a relation.
|
* This class represents a relation.
|
||||||
* It allows a better right management of the meta informations.
|
* It allows a better right management of the meta informations.
|
||||||
* Also it is used to capsel the logic relation to an own logical unit.
|
* Also it is used to capsel the logic relation to an own logical unit.
|
||||||
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
|
*
|
||||||
* @todo rename and refactor this class
|
* @todo rename and refactor this class
|
||||||
* @ORM\Table(name="meta_relation")
|
* @ORM\Table(name="meta_relation")
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
@ -28,9 +30,10 @@ final class Relation extends AbstractMeta implements RelationInterface
|
|||||||
ParentsAttribut,
|
ParentsAttribut,
|
||||||
LawAttribut,
|
LawAttribut,
|
||||||
ChildsAttribut;
|
ChildsAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parents represent the creators of the relation
|
* Parents represent the creators of the relation.
|
||||||
|
*
|
||||||
* @ORM\ManyToMany(targetEntity="Relation")
|
* @ORM\ManyToMany(targetEntity="Relation")
|
||||||
* @ORM\JoinTable(name="meta_relation_parents",
|
* @ORM\JoinTable(name="meta_relation_parents",
|
||||||
* joinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")},
|
* joinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")},
|
||||||
@ -40,10 +43,12 @@ final class Relation extends AbstractMeta implements RelationInterface
|
|||||||
* @var Collection|RelationInterface[]
|
* @var Collection|RelationInterface[]
|
||||||
*/
|
*/
|
||||||
protected $parents;
|
protected $parents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Childs represent the by the object produced relations
|
* Childs represent the by the object produced relations.
|
||||||
* @todo Replace this by self referencing
|
*
|
||||||
|
* @todo Replace this by self referencing
|
||||||
|
*
|
||||||
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html
|
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html
|
||||||
* @ORM\ManyToMany(targetEntity="Relation")
|
* @ORM\ManyToMany(targetEntity="Relation")
|
||||||
* @ORM\JoinTable(name="meta_relation_childs",
|
* @ORM\JoinTable(name="meta_relation_childs",
|
||||||
|
@ -11,6 +11,6 @@ use App\Entity\Attribut\LawAttributInterface;
|
|||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface RelationInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface, LawAttributInterface,MetaInterface
|
interface RelationInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface, LawAttributInterface, MetaInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Meta;
|
namespace App\Entity\Meta;
|
||||||
|
|
||||||
use App\Entity\Attribut\TypeAttributInterface;
|
use App\Entity\Attribut\TypeAttributInterface;
|
||||||
@ -11,7 +12,6 @@ use App\Entity\Method\RelationGrantedInterface;
|
|||||||
use App\Entity\Attribut\RelationAttributInterface;
|
use App\Entity\Attribut\RelationAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverGroupAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverGroupAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
||||||
|
@ -11,9 +11,11 @@ interface RelationGrantedInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @deprecated Methods shouldn't be used on the entity level
|
* @deprecated Methods shouldn't be used on the entity level
|
||||||
|
*
|
||||||
* @param RelationInterface $relation
|
* @param RelationInterface $relation
|
||||||
* @param string $layer
|
* @param string $layer
|
||||||
* @param string $right
|
* @param string $right
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isGranted(RelationInterface $relation, string $layer, string $right): bool;
|
public function isGranted(RelationInterface $relation, string $layer, string $right): bool;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source;
|
namespace App\Entity\Source;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
@ -15,9 +16,8 @@ use App\Entity\Meta\Law;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
*
|
||||||
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html
|
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="source")
|
* @ORM\Table(name="source")
|
||||||
@ -30,7 +30,6 @@ abstract class AbstractSource extends AbstractEntity implements SourceInterface
|
|||||||
use RelationAttribut,GroupSourcesAttribut, LawAttribut;
|
use RelationAttribut,GroupSourcesAttribut, LawAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var RelationInterface
|
* @var RelationInterface
|
||||||
* @ORM\OneToOne(targetEntity="App\Entity\Meta\Relation",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="App\Entity\Meta\Relation",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
||||||
@ -39,16 +38,15 @@ abstract class AbstractSource extends AbstractEntity implements SourceInterface
|
|||||||
protected $relation;
|
protected $relation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @todo Implement that just one table on database level is needed!
|
* @todo Implement that just one table on database level is needed!
|
||||||
* @todo Rename table to use the right schema
|
* @todo Rename table to use the right schema
|
||||||
|
*
|
||||||
* @var Collection|GroupSource[]
|
* @var Collection|GroupSource[]
|
||||||
* @ORM\ManyToMany(targetEntity="GroupSource")
|
* @ORM\ManyToMany(targetEntity="GroupSource")
|
||||||
*/
|
*/
|
||||||
protected $groups;
|
protected $groups;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @ORM\OneToOne(targetEntity="Law",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="Law",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
||||||
*
|
*
|
||||||
|
@ -1,36 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Attribut;
|
namespace App\Entity\Source\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use App\Entity\Source\GroupSourceInterface;
|
use App\Entity\Source\GroupSourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait GroupSourcesAttribut
|
trait GroupSourcesAttribut
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var Collection|GroupSourceInterface[]
|
* @var Collection|GroupSourceInterface[]
|
||||||
*/
|
*/
|
||||||
protected $groups;
|
protected $groups;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return Collection|GroupSourceInterface[]
|
* @return Collection|GroupSourceInterface[]
|
||||||
*/
|
*/
|
||||||
public function getGroupSources():Collection{
|
public function getGroupSources(): Collection
|
||||||
|
{
|
||||||
return $this->groups;
|
return $this->groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param Collection|GroupSourceInterface[] $groups
|
* @param Collection|GroupSourceInterface[] $groups
|
||||||
*/
|
*/
|
||||||
public function setGroupSources(Collection $groups):void{
|
public function setGroupSources(Collection $groups): void
|
||||||
|
{
|
||||||
$this->groups = $groups;
|
$this->groups = $groups;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Attribut;
|
namespace App\Entity\Source\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use App\Entity\Source\GroupSourceInterface;
|
use App\Entity\Source\GroupSourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface GroupSourcesAttributInterface
|
interface GroupSourcesAttributInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param Collection|GroupSourceInterface[] $groups
|
* @param Collection|GroupSourceInterface[] $groups
|
||||||
*/
|
*/
|
||||||
public function setGroupSources(Collection $groups):void;
|
public function setGroupSources(Collection $groups): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection|GroupSourceInterface[]
|
* @return Collection|GroupSourceInterface[]
|
||||||
*/
|
*/
|
||||||
public function getGroupSources():Collection;
|
public function getGroupSources(): Collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Attribut;
|
namespace App\Entity\Source\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait MembersAttribut
|
trait MembersAttribut
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var Collection
|
* @var Collection
|
||||||
*/
|
*/
|
||||||
protected $members;
|
protected $members;
|
||||||
@ -27,4 +24,3 @@ trait MembersAttribut
|
|||||||
$this->members = $members;
|
$this->members = $members;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Attribut;
|
namespace App\Entity\Source\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to group other sources in a source
|
* Allows to group other sources in a source.
|
||||||
*
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface MembersAttributInterface
|
interface MembersAttributInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $members
|
* @param Collection $members
|
||||||
*/
|
*/
|
||||||
@ -21,4 +20,4 @@ interface MembersAttributInterface
|
|||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getMembers(): Collection;
|
public function getMembers(): Collection;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source;
|
namespace App\Entity\Source;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
@ -8,7 +9,6 @@ use App\Entity\Source\Attribut\MembersAttribut;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
* @ORM\Table(name="source_group")
|
* @ORM\Table(name="source_group")
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
@ -18,15 +18,14 @@ final class GroupSource extends AbstractSource implements MembersAttributInterfa
|
|||||||
use MembersAttribut;
|
use MembersAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var Collection
|
* @var Collection
|
||||||
* @ORM\ManyToMany(targetEntity="AbstractSource")
|
* @ORM\ManyToMany(targetEntity="AbstractSource")
|
||||||
*/
|
*/
|
||||||
protected $members;
|
protected $members;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->members = new ArrayCollection();
|
$this->members = new ArrayCollection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source;
|
namespace App\Entity\Source;
|
||||||
|
|
||||||
use App\Entity\Source\Attribut\MembersAttributInterface;
|
use App\Entity\Source\Attribut\MembersAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
|
*
|
||||||
* @todo Map the not jet mapped functions!
|
* @todo Map the not jet mapped functions!
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface GroupSourceInterface extends MembersAttributInterface
|
interface GroupSourceInterface extends MembersAttributInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ namespace App\Entity\Source;
|
|||||||
use App\Entity\Attribut\NameAttribut;
|
use App\Entity\Attribut\NameAttribut;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
use App\Entity\Source\NameSourceInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Operation;
|
namespace App\Entity\Source\Operation;
|
||||||
|
|
||||||
use App\Logic\Result\ResultInterface;
|
use App\Logic\Result\ResultInterface;
|
||||||
@ -9,7 +10,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use App\Entity\Source\AbstractSource;
|
use App\Entity\Source\AbstractSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="source_operation")
|
* @ORM\Table(name="source_operation")
|
||||||
@ -19,7 +19,6 @@ use App\Entity\Source\AbstractSource;
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractOperation extends AbstractSource implements OperationInterface
|
abstract class AbstractOperation extends AbstractSource implements OperationInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result MUST NOT be saved via Doctrine!
|
* The result MUST NOT be saved via Doctrine!
|
||||||
*
|
*
|
||||||
@ -28,7 +27,6 @@ abstract class AbstractOperation extends AbstractSource implements OperationInte
|
|||||||
protected $result;
|
protected $result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var ArrayCollection|OperandInterface[]
|
* @var ArrayCollection|OperandInterface[]
|
||||||
*/
|
*/
|
||||||
protected $operands;
|
protected $operands;
|
||||||
|
@ -19,12 +19,13 @@ class AndOperation extends AbstractOperation
|
|||||||
throw new \Exception('Operands must be defined!');
|
throw new \Exception('Operands must be defined!');
|
||||||
}
|
}
|
||||||
$this->result = new Result();
|
$this->result = new Result();
|
||||||
/**
|
/*
|
||||||
* @var OperandInterface
|
* @var OperandInterface
|
||||||
*/
|
*/
|
||||||
foreach ($this->operands->toArray() as $operand) {
|
foreach ($this->operands->toArray() as $operand) {
|
||||||
if (!$operand->getResult()->getBool()) {
|
if (!$operand->getResult()->getBool()) {
|
||||||
$this->result->setAll(false);
|
$this->result->setAll(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source;
|
namespace App\Entity\Source;
|
||||||
|
|
||||||
use App\Entity\Attribut\IdAttributInterface;
|
use App\Entity\Attribut\IdAttributInterface;
|
||||||
@ -7,7 +8,6 @@ use App\Entity\Source\Attribut\GroupSourcesAttributInterface;
|
|||||||
use App\Entity\Attribut\LawAttributInterface;
|
use App\Entity\Attribut\LawAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface SourceInterface extends IdAttributInterface, EntityInterface, GroupSourcesAttributInterface, LawAttributInterface
|
interface SourceInterface extends IdAttributInterface, EntityInterface, GroupSourcesAttributInterface, LawAttributInterface
|
||||||
|
@ -38,10 +38,10 @@ class User extends BaseUser implements UserInterface
|
|||||||
* @ORM\Column(type="integer")(strategy="AUTO")
|
* @ORM\Column(type="integer")(strategy="AUTO")
|
||||||
*/
|
*/
|
||||||
protected $id;
|
protected $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @version @ORM\Column(type="integer")
|
* @version @ORM\Column(type="integer")
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $version;
|
protected $version;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use FOS\UserBundle\Model\UserInterface as FOSUserInterface;
|
use FOS\UserBundle\Model\UserInterface as FOSUserInterface;
|
||||||
@ -7,9 +8,7 @@ use App\Entity\Attribut\VersionAttributInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface UserInterface extends FOSUserInterface, SourceAttributInterface, VersionAttributInterface
|
interface UserInterface extends FOSUserInterface, SourceAttributInterface, VersionAttributInterface
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Event\Menu;
|
namespace App\Event\Menu;
|
||||||
|
|
||||||
use Knp\Menu\FactoryInterface;
|
use Knp\Menu\FactoryInterface;
|
||||||
@ -7,9 +8,7 @@ use Symfony\Component\EventDispatcher\Event;
|
|||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class MenuEvent extends Event
|
class MenuEvent extends Event
|
||||||
{
|
{
|
||||||
@ -17,24 +16,24 @@ class MenuEvent extends Event
|
|||||||
* @var FactoryInterface
|
* @var FactoryInterface
|
||||||
*/
|
*/
|
||||||
private $factory;
|
private $factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ItemInterface
|
* @var ItemInterface
|
||||||
*/
|
*/
|
||||||
private $item;
|
private $item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RequestStack
|
* @var RequestStack
|
||||||
*/
|
*/
|
||||||
private $request;
|
private $request;
|
||||||
|
|
||||||
public function __construct(FactoryInterface $factory, ItemInterface $item, RequestStack $request)
|
public function __construct(FactoryInterface $factory, ItemInterface $item, RequestStack $request)
|
||||||
{
|
{
|
||||||
$this->factory = $factory;
|
$this->factory = $factory;
|
||||||
$this->item = $item;
|
$this->item = $item;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return FactoryInterface
|
* @return FactoryInterface
|
||||||
*/
|
*/
|
||||||
@ -42,7 +41,7 @@ class MenuEvent extends Event
|
|||||||
{
|
{
|
||||||
return $this->factory;
|
return $this->factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ItemInterface
|
* @return ItemInterface
|
||||||
*/
|
*/
|
||||||
@ -50,7 +49,7 @@ class MenuEvent extends Event
|
|||||||
{
|
{
|
||||||
return $this->item;
|
return $this->item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return RequestStack
|
* @return RequestStack
|
||||||
*/
|
*/
|
||||||
@ -58,4 +57,4 @@ class MenuEvent extends Event
|
|||||||
{
|
{
|
||||||
return $this->request;
|
return $this->request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Menu;
|
namespace App\Menu;
|
||||||
|
|
||||||
use Knp\Menu\FactoryInterface;
|
use Knp\Menu\FactoryInterface;
|
||||||
@ -10,15 +11,12 @@ use App\DBAL\Types\MenuEventType;
|
|||||||
|
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var EventDispatcherInterface
|
* @var EventDispatcherInterface
|
||||||
*/
|
*/
|
||||||
private $dispatcher;
|
private $dispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var FactoryInterface
|
* @var FactoryInterface
|
||||||
*/
|
*/
|
||||||
private $factory;
|
private $factory;
|
||||||
@ -48,6 +46,7 @@ class Menu
|
|||||||
{
|
{
|
||||||
$menu = $this->createBasicMenuItem();
|
$menu = $this->createBasicMenuItem();
|
||||||
$this->dispatcher->dispatch($type, new MenuEvent($this->factory, $menu, $request));
|
$this->dispatcher->dispatch($type, new MenuEvent($this->factory, $menu, $request));
|
||||||
|
|
||||||
return $menu;
|
return $menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +54,8 @@ class Menu
|
|||||||
{
|
{
|
||||||
return $this->factory->createItem('root', [
|
return $this->factory->createItem('root', [
|
||||||
'childrenAttributes' => [
|
'childrenAttributes' => [
|
||||||
'class' => 'navbar-nav mr-auto'
|
'class' => 'navbar-nav mr-auto',
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class LawRepository extends EntityRepository
|
class LawRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Security;
|
namespace App\Security;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
@ -9,54 +10,57 @@ use App\DBAL\Types\LayerType;
|
|||||||
use App\Entity\UserInterface;
|
use App\Entity\UserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
|
*
|
||||||
* @see https://symfony.com/doc/current/security/voters.html
|
* @see https://symfony.com/doc/current/security/voters.html
|
||||||
*/
|
*/
|
||||||
class SourceVoter extends Voter
|
class SourceVoter extends Voter
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @var string[]
|
||||||
* @var string[] $attribute
|
|
||||||
* @var SourceInterface $subject
|
* @var SourceInterface $subject
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
* @see \Symfony\Component\Security\Core\Authorization\Voter\Voter::supports()
|
* @see \Symfony\Component\Security\Core\Authorization\Voter\Voter::supports()
|
||||||
*/
|
*/
|
||||||
protected function supports($attribute, $subject)
|
protected function supports($attribute, $subject)
|
||||||
{
|
{
|
||||||
return $this->checkInstance($subject) && $this->checkRight($attribute);
|
return $this->checkInstance($subject) && $this->checkRight($attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
//private function checkLayer(string $layer):bool{
|
//private function checkLayer(string $layer):bool{
|
||||||
// return (in_array($right, array_keys(LayerType::getChoices())));
|
// return (in_array($right, array_keys(LayerType::getChoices())));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private function checkRight(string $right):bool{
|
private function checkRight(string $right): bool
|
||||||
return (in_array($right, array_keys(RightType::getChoices())));
|
{
|
||||||
|
return in_array($right, array_keys(RightType::getChoices()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkInstance($subject):bool{
|
private function checkInstance($subject): bool
|
||||||
return ($subject instanceof SourceInterface);
|
{
|
||||||
|
return $subject instanceof SourceInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo add if father, that it should have all rights!
|
* @todo add if father, that it should have all rights!
|
||||||
* @param string[] $attribute
|
*
|
||||||
|
* @param string[] $attribute
|
||||||
* @param SourceInterface $subject
|
* @param SourceInterface $subject
|
||||||
* @param TokenInterface $token
|
* @param TokenInterface $token
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
* @see \Symfony\Component\Security\Core\Authorization\Voter\Voter::voteOnAttribute()
|
* @see \Symfony\Component\Security\Core\Authorization\Voter\Voter::voteOnAttribute()
|
||||||
*/
|
*/
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var UserInterface $user
|
* @var UserInterface
|
||||||
*/
|
*/
|
||||||
$user = $token->getUser();
|
$user = $token->getUser();
|
||||||
|
|
||||||
return $subject->getNode()
|
return $subject->getNode()
|
||||||
->getLaw()
|
->getLaw()
|
||||||
->isGranted($user->getSource()->getNode(), LayerType::SOURCE, $attribute);
|
->isGranted($user->getSource()->getNode(), LayerType::SOURCE, $attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ use App\Entity\Source\SourceInterface;
|
|||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\DBAL\Types\RightType;
|
use App\DBAL\Types\RightType;
|
||||||
use App\DBAL\Types\LayerType;
|
use App\DBAL\Types\LayerType;
|
||||||
use App\Structur\Facade\Security\Source\SourceFacadeInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -15,7 +14,8 @@ use App\Structur\Facade\Security\Source\SourceFacadeInterface;
|
|||||||
abstract class AbstractSourceFacade implements SourceFacadeInterface
|
abstract class AbstractSourceFacade implements SourceFacadeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Propably it woul be better to solve this over the constructor
|
* Propably it woul be better to solve this over the constructor.
|
||||||
|
*
|
||||||
* @var User
|
* @var User
|
||||||
*/
|
*/
|
||||||
protected static $facadeUser;
|
protected static $facadeUser;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Structur\Facade\Security\Source;
|
namespace App\Structur\Facade\Security\Source;
|
||||||
|
|
||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface SourceFacadeInterface extends SourceInterface
|
interface SourceFacadeInterface extends SourceInterface
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Structur\Facade\Security\Source;
|
namespace App\Structur\Facade\Security\Source;
|
||||||
|
|
||||||
use App\Entity\Meta\LawInterface;
|
use App\Entity\Meta\LawInterface;
|
||||||
@ -12,13 +13,12 @@ use Doctrine\Common\Collections\Collection;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo check if this layer makes sense
|
* @todo check if this layer makes sense
|
||||||
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterface
|
class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var UserSourceInterface
|
* @var UserSourceInterface
|
||||||
*/
|
*/
|
||||||
protected $source;
|
protected $source;
|
||||||
@ -45,61 +45,64 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getUser(): UserInterface
|
public function getUser(): UserInterface
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function setUser(UserInterface $user): void
|
public function setUser(UserInterface $user): void
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function getVersion(): int
|
public function getVersion(): int
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setVersion(int $version): void
|
public function setVersion(int $version): void
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSource(SourceInterface $source): void
|
public function setSource(SourceInterface $source): void
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGroupSources(): Collection
|
public function getGroupSources(): Collection
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSource(): SourceInterface
|
public function getSource(): SourceInterface
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setGroupSources(Collection $groups): void
|
public function setGroupSources(Collection $groups): void
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLaw(LawInterface $law): void
|
public function setLaw(LawInterface $law): void
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
@ -107,10 +110,9 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
|
|||||||
|
|
||||||
public function getLaw(): LawInterface
|
public function getLaw(): LawInterface
|
||||||
{
|
{
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* @todo Implement
|
* @todo Implement
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Subscriber;
|
namespace App\Subscriber;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
@ -7,9 +8,7 @@ use Symfony\Component\EventDispatcher\Event;
|
|||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
|
abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
@ -17,52 +16,53 @@ abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
|
|||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
private $translator;
|
private $translator;
|
||||||
|
|
||||||
const FORMAT_TYPES = [
|
const FORMAT_TYPES = [
|
||||||
'html',
|
'html',
|
||||||
'json',
|
'json',
|
||||||
'xml'
|
'xml',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator)
|
public function __construct(TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateShowDropdown(ItemInterface $menu, Event $event,string $route): void
|
protected function generateShowDropdown(ItemInterface $menu, Event $event, string $route): void
|
||||||
{
|
{
|
||||||
$dropdown = $menu->addChild($this->trans('show'), [
|
$dropdown = $menu->addChild($this->trans('show'), [
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'icon' => 'fas fa-eye',
|
'icon' => 'fas fa-eye',
|
||||||
'dropdown' => 'true'
|
'dropdown' => 'true',
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
foreach (self::FORMAT_TYPES as $format) {
|
foreach (self::FORMAT_TYPES as $format) {
|
||||||
$dropdown->addChild($format, [
|
$dropdown->addChild($format, [
|
||||||
'route' => $route,
|
'route' => $route,
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'id' => $this->getRequestId($event),
|
'id' => $this->getRequestId($event),
|
||||||
'_format' => $format
|
'_format' => $format,
|
||||||
],
|
],
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'icon' => 'fas fa-sign-out-alt',
|
'icon' => 'fas fa-sign-out-alt',
|
||||||
'divider_append' => true
|
'divider_append' => true,
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$dropdown->addChild($this->trans('standard'), [
|
$dropdown->addChild($this->trans('standard'), [
|
||||||
'route' => $route,
|
'route' => $route,
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'id' => $this->getRequestId($event)
|
'id' => $this->getRequestId($event),
|
||||||
],
|
],
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'icon' => 'fas fa-sign-out-alt'
|
'icon' => 'fas fa-sign-out-alt',
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function trans(string $id, array $parameter=[]):string{
|
protected function trans(string $id, array $parameter = []): string
|
||||||
return $this->translator->trans($id,$parameter);
|
{
|
||||||
|
return $this->translator->trans($id, $parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRequestId(Event $event): int
|
protected function getRequestId(Event $event): int
|
||||||
@ -70,4 +70,3 @@ abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
|
|||||||
return $event->getRequest()->getCurrentRequest()->attributes->get('id');
|
return $event->getRequest()->getCurrentRequest()->attributes->get('id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Subscriber;
|
namespace App\Subscriber;
|
||||||
|
|
||||||
use App\DBAL\Types\MenuEventType;
|
use App\DBAL\Types\MenuEventType;
|
||||||
use App\Event\Menu\MenuEvent;
|
use App\Event\Menu\MenuEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class NodeMenuSubscriber extends AbstractEntityMenuSubscriber
|
class NodeMenuSubscriber extends AbstractEntityMenuSubscriber
|
||||||
{
|
{
|
||||||
public function onNodeMenuConfigure(MenuEvent $event): void
|
public function onNodeMenuConfigure(MenuEvent $event): void
|
||||||
{
|
{
|
||||||
$menu = $event->getItem();
|
$menu = $event->getItem();
|
||||||
$this->generateShowDropdown($menu, $event,'app_source_show');
|
$this->generateShowDropdown($menu, $event, 'app_source_show');
|
||||||
$menu->addChild($this->trans('law'), [
|
$menu->addChild($this->trans('law'), [
|
||||||
'route' => 'app_node_law',
|
'route' => 'app_node_law',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
@ -43,12 +42,11 @@ class NodeMenuSubscriber extends AbstractEntityMenuSubscriber
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
MenuEventType::NODE => 'onNodeMenuConfigure'
|
MenuEventType::NODE => 'onNodeMenuConfigure',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class SourceMenuSubscriber extends AbstractEntityMenuSubscriber
|
|||||||
'icon' => 'fas fa-edit',
|
'icon' => 'fas fa-edit',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->generateShowDropdown($menu, $event,'app_source_show');
|
$this->generateShowDropdown($menu, $event, 'app_source_show');
|
||||||
$menu->addChild($this->trans('node'), [
|
$menu->addChild($this->trans('node'), [
|
||||||
'route' => 'app_source_node',
|
'route' => 'app_source_node',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
|
@ -90,7 +90,7 @@ class UserMenuSubscriber implements EventSubscriberInterface
|
|||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
MenuEventType::USER=> 'onUserMenuConfigure',
|
MenuEventType::USER => 'onUserMenuConfigure',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\unit\Entity\Source;
|
namespace tests\unit\Entity\Source;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -10,9 +11,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
use App\Entity\Source\AbstractSource;
|
use App\Entity\Source\AbstractSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class AbstractSourceTest extends TestCase
|
class AbstractSourceTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -21,30 +20,36 @@ class AbstractSourceTest extends TestCase
|
|||||||
* @var SourceInterface
|
* @var SourceInterface
|
||||||
*/
|
*/
|
||||||
protected $source;
|
protected $source;
|
||||||
|
|
||||||
public function setUp(){
|
public function setUp()
|
||||||
$this->source = new class extends \App\Entity\Source\AbstractSource{};
|
{
|
||||||
|
$this->source = new class() extends \App\Entity\Source\AbstractSource {
|
||||||
|
};
|
||||||
$this->source->setId(self::ID);
|
$this->source->setId(self::ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testId(){
|
public function testId()
|
||||||
$this->assertEquals($this->source->getId(),self::ID);
|
{
|
||||||
|
$this->assertEquals($this->source->getId(), self::ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLaw(){
|
public function testLaw()
|
||||||
$this->assertInstanceOf(LawInterface::class,$this->source->getLaw());
|
{
|
||||||
|
$this->assertInstanceOf(LawInterface::class, $this->source->getLaw());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRelation(){
|
public function testRelation()
|
||||||
$this->assertInstanceOf(RelationInterface::class,$this->source->getRelation());
|
{
|
||||||
|
$this->assertInstanceOf(RelationInterface::class, $this->source->getRelation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGroups(){
|
public function testGroups()
|
||||||
$this->assertInstanceOf(Collection::class,$this->source->getGroupSources());
|
{
|
||||||
$group = new class extends AbstractSource{};
|
$this->assertInstanceOf(Collection::class, $this->source->getGroupSources());
|
||||||
|
$group = new class() extends AbstractSource {
|
||||||
|
};
|
||||||
$groups = new ArrayCollection([$group]);
|
$groups = new ArrayCollection([$group]);
|
||||||
$this->source->setGroupSources($groups);
|
$this->source->setGroupSources($groups);
|
||||||
$this->assertEquals($group, $this->source->getGroupSources()->get(0));
|
$this->assertEquals($group, $this->source->getGroupSources()->get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\unit\Entity\Source;
|
namespace tests\unit\Entity\Source;
|
||||||
|
|
||||||
use App\Entity\Source\GroupSourceInterface;
|
use App\Entity\Source\GroupSourceInterface;
|
||||||
@ -9,27 +10,26 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
use App\Entity\Source\AbstractSource;
|
use App\Entity\Source\AbstractSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class GroupSourceTest extends TestCase
|
class GroupSourceTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var GroupSourceInterface
|
* @var GroupSourceInterface
|
||||||
*/
|
*/
|
||||||
protected $groupSource;
|
protected $groupSource;
|
||||||
|
|
||||||
public function setUp():void {
|
public function setUp(): void
|
||||||
|
{
|
||||||
$this->groupSource = new GroupSource();
|
$this->groupSource = new GroupSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMembers(){
|
public function testMembers()
|
||||||
|
{
|
||||||
$this->assertInstanceOf(Collection::class, $this->groupSource->getMembers());
|
$this->assertInstanceOf(Collection::class, $this->groupSource->getMembers());
|
||||||
$member = new class extends AbstractSource{};
|
$member = new class() extends AbstractSource {
|
||||||
|
};
|
||||||
$this->groupSource->setMembers(new ArrayCollection([$member]));
|
$this->groupSource->setMembers(new ArrayCollection([$member]));
|
||||||
$this->assertEquals($member, $this->groupSource->getMembers()->get(0));
|
$this->assertEquals($member, $this->groupSource->getMembers()->get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\unit\Entity\Source;
|
namespace tests\unit\Entity\Source;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -6,15 +7,11 @@ use App\Entity\Source\NameSourceInterface;
|
|||||||
use App\Entity\Source\NameSource;
|
use App\Entity\Source\NameSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class NameSourceTest extends TestCase
|
class NameSourceTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var NameSourceInterface
|
* @var NameSourceInterface
|
||||||
*/
|
*/
|
||||||
protected $nameSource;
|
protected $nameSource;
|
||||||
@ -23,12 +20,12 @@ class NameSourceTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->nameSource = new NameSource();
|
$this->nameSource = new NameSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testName():void{
|
public function testName(): void
|
||||||
|
{
|
||||||
$this->assertEquals('', $this->nameSource->getName());
|
$this->assertEquals('', $this->nameSource->getName());
|
||||||
$name = 'Hello World!';
|
$name = 'Hello World!';
|
||||||
$this->nameSource->setName($name);
|
$this->nameSource->setName($name);
|
||||||
$this->assertEquals($name, $this->nameSource->getName());
|
$this->assertEquals($name, $this->nameSource->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ class UserTest extends TestCase
|
|||||||
$this->user = new User();
|
$this->user = new User();
|
||||||
$this->user->setUsername(self::USERNAME);
|
$this->user->setUsername(self::USERNAME);
|
||||||
$this->user->setPassword(self::PASSWORD);
|
$this->user->setPassword(self::PASSWORD);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstructor():void{
|
public function testConstructor(): void
|
||||||
|
{
|
||||||
$this->assertInstanceOf(UserInterface::class, new User());
|
$this->assertInstanceOf(UserInterface::class, new User());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user