Applied CS fixer

This commit is contained in:
Kevin Frantz 2018-10-29 19:01:00 +01:00
parent 91c41105c7
commit 6bc95f9729
46 changed files with 270 additions and 281 deletions

View File

@ -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
{ {
@ -17,7 +16,8 @@ abstract class AbstractEntityController extends FOSRestController
*/ */
protected $entityName; protected $entityName;
public function __construct(){ public function __construct()
{
$this->setEntityName(); $this->setEntityName();
} }
@ -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,
]); ]);
} }
} }

View File

@ -1,57 +1,53 @@
<?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!
*/ */

View File

@ -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,12 +23,13 @@ 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);
} }
@ -37,14 +39,16 @@ class NodeController extends AbstractEntityController
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
*/ */
} }
@ -52,8 +56,9 @@ class NodeController extends AbstractEntityController
/** /**
* @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
*/ */
} }

View File

@ -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
@ -40,7 +36,6 @@ class SourceController extends AbstractEntityController
} }
/** /**
*
* @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
@ -54,21 +49,22 @@ class SourceController extends AbstractEntityController
} }
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();
} }

View File

@ -6,7 +6,8 @@ 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
@ -18,7 +19,8 @@ final class MenuEventType extends AbstractEnumType
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 = [];

View File

@ -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;

View File

@ -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;
} }
} }

View File

@ -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;
} }

View File

@ -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
{ {
} }

View File

@ -1,12 +1,11 @@
<?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
{ {

View File

@ -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
*/ */

View File

@ -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;
/** /**

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Entity\Meta; namespace App\Entity\Meta;
use App\Entity\EntityInterface; use App\Entity\EntityInterface;
@ -6,10 +7,9 @@ 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
{ {
} }

View File

@ -16,7 +16,9 @@ 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()
@ -30,7 +32,8 @@ final class Relation extends AbstractMeta implements RelationInterface
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")},
@ -42,8 +45,10 @@ final class Relation extends AbstractMeta implements 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",

View File

@ -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

View File

@ -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;

View File

@ -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,7 +16,6 @@ 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
@ -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")
* *

View File

@ -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;
} }
} }

View File

@ -1,13 +1,12 @@
<?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
{ {
@ -21,4 +20,3 @@ interface GroupSourcesAttributInterface
*/ */
public function getGroupSources(): Collection; public function getGroupSources(): Collection;
} }

View File

@ -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;
} }
} }

View File

@ -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
*/ */

View File

@ -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();
} }
} }

View File

@ -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
{ {
} }

View File

@ -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

View File

@ -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;

View File

@ -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;
} }
} }

View File

@ -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

View File

@ -40,8 +40,8 @@ class User extends BaseUser implements UserInterface
protected $id; protected $id;
/** /**
*
* @version @ORM\Column(type="integer") * @version @ORM\Column(type="integer")
*
* @var int * @var int
*/ */
protected $version; protected $version;

View File

@ -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
{ {
} }

View File

@ -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
{ {

View File

@ -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',
] ],
]); ]);
} }
} }

View File

@ -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
{ {
} }

View File

@ -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,18 +10,17 @@ 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)
@ -32,31 +32,35 @@ class SourceVoter extends Voter
// 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);
} }
} }

View File

@ -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;

View File

@ -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

View File

@ -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,14 +45,16 @@ 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
*/ */
@ -60,7 +62,7 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
public function setVersion(int $version): void public function setVersion(int $version): void
{ {
/** /*
* *
* @todo Implement * @todo Implement
*/ */
@ -68,7 +70,7 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
public function setSource(SourceInterface $source): void public function setSource(SourceInterface $source): void
{ {
/** /*
* *
* @todo Implement * @todo Implement
*/ */
@ -76,7 +78,7 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
public function getGroupSources(): Collection public function getGroupSources(): Collection
{ {
/** /*
* *
* @todo Implement * @todo Implement
*/ */
@ -84,7 +86,7 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
public function getSource(): SourceInterface public function getSource(): SourceInterface
{ {
/** /*
* *
* @todo Implement * @todo Implement
*/ */
@ -92,14 +94,15 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
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
*/ */
} }
} }

View File

@ -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
{ {
@ -21,7 +20,7 @@ abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
const FORMAT_TYPES = [ const FORMAT_TYPES = [
'html', 'html',
'json', 'json',
'xml' 'xml',
]; ];
public function __construct(TranslatorInterface $translator) public function __construct(TranslatorInterface $translator)
@ -34,34 +33,35 @@ abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
$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);
} }
@ -70,4 +70,3 @@ abstract class AbstractEntityMenuSubscriber implements EventSubscriberInterface
return $event->getRequest()->getCurrentRequest()->attributes->get('id'); return $event->getRequest()->getCurrentRequest()->attributes->get('id');
} }
} }

View File

@ -1,13 +1,12 @@
<?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
{ {
@ -47,8 +46,7 @@ class NodeMenuSubscriber extends AbstractEntityMenuSubscriber
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return [ return [
MenuEventType::NODE => 'onNodeMenuConfigure' MenuEventType::NODE => 'onNodeMenuConfigure',
]; ];
} }
} }

View File

@ -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
{ {
@ -22,29 +21,35 @@ class AbstractSourceTest extends TestCase
*/ */
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()); $this->assertInstanceOf(Collection::class, $this->source->getGroupSources());
$group = new class extends AbstractSource{}; $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));
} }
} }

View File

@ -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));
} }
} }

View File

@ -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;
@ -24,11 +21,11 @@ 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());
} }
} }

View File

@ -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());
} }