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