Moved meta entities to meta

This commit is contained in:
Kevin Frantz 2018-10-28 15:25:32 +01:00
parent 5af5a6b5e2
commit 25020bbe97
23 changed files with 76 additions and 44 deletions

View File

@ -5,8 +5,8 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use App\Entity\Law;
use App\Entity\LawInterface;
use App\Entity\Meta\Law;
use App\Entity\Meta\LawInterface;
/**
*

View File

@ -4,20 +4,20 @@ namespace App\Creator\Modificator\Entity;
use App\DBAL\Types\LayerType;
use App\DBAL\Types\RightType;
use App\Entity\NodeInterface;
use App\Entity\Right;
use App\Entity\LawInterface;
use App\Entity\Meta\RelationInterface;
use App\Entity\Meta\Right;
use App\Entity\Meta\LawInterface;
use App\DBAL\Types\RecieverType;
use App\Entity\RightInterface;
use App\Entity\RecieverGroupInterface;
use App\Entity\RecieverGroup;
use App\Entity\Meta\RightInterface;
use App\Entity\Meta\RecieverGroupInterface;
use App\Entity\Meta\RecieverGroup;
/**
* @author kevinfrantz
*/
abstract class LawModificator
{
public static function grantAllRights(LawInterface $law, NodeInterface $node): void
public static function grantAllRights(LawInterface $law, RelationInterface $node): void
{
foreach (LayerType::getChoices() as $layerKey => $layerValue) {
foreach (RightType::getChoices() as $rightKey => $rightValue) {
@ -28,7 +28,7 @@ abstract class LawModificator
}
}
public static function createRight(LawInterface $law, NodeInterface $node, string $type, string $layer): RightInterface
public static function createRight(LawInterface $law, RelationInterface $node, string $type, string $layer): RightInterface
{
$right = new Right();
$right->setType($type);
@ -39,7 +39,7 @@ abstract class LawModificator
return $right;
}
public static function createRecieverGroup(NodeInterface $node, string $reciever): RecieverGroupInterface
public static function createRecieverGroup(RelationInterface $node, string $reciever): RecieverGroupInterface
{
$recieverGroup = new RecieverGroup();
$recieverGroup->setNode($node);

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\LawInterface;
use App\Entity\Meta\LawInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\LawInterface;
use App\Entity\Meta\LawInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\RecieverGroupInterface;
use App\Entity\Meta\RecieverGroupInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\RecieverGroupInterface;
use App\Entity\Meta\RecieverGroupInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\RelationInterface;
use App\Entity\Meta\RelationInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\RelationInterface;
use App\Entity\Meta\RelationInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\RightInterface;
use App\Entity\Meta\RightInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\RightInterface;
use App\Entity\Meta\RightInterface;
/**
* @author kevinfrantz

View File

@ -0,0 +1,13 @@
<?php
namespace App\Entity\Meta;
use App\Entity\AbstractEntity;
/**
*
* @author kevinfrantz
*
*/
abstract class AbstractMeta extends AbstractEntity implements MetaInterface
{
}

View File

@ -1,6 +1,5 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\RightsAttribute;
@ -8,15 +7,17 @@ use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Attribut\RelationAttribut;
/**
*
* @author kevinfrantz
* @ORM\Table(name="law")
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
*/
class Law extends AbstractEntity implements LawInterface
class Law extends AbstractMeta implements LawInterface
{
use RightsAttribute, RelationAttribut;
/**
*
* @ORM\OneToMany(targetEntity="Right", mappedBy="law", cascade={"persist", "remove"})
*
* @var ArrayCollection | Right[]
@ -24,6 +25,7 @@ class Law extends AbstractEntity implements LawInterface
protected $rights;
/**
*
* @ORM\OneToOne(targetEntity="Relation",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
*
@ -44,6 +46,7 @@ class Law extends AbstractEntity implements LawInterface
public function isGranted(RelationInterface $relation, string $layer, string $right): bool
{
/**
*
* @var RightInterface
*/
foreach ($this->rights->toArray() as $right) {

View File

@ -1,6 +1,6 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use App\Entity\Attribut\RightsAttributInterface;
use App\Entity\Attribut\RelationAttributInterface;
@ -9,6 +9,6 @@ use App\Entity\Method\RelationGrantedInterface;
/**
* @author kevinfrantz
*/
interface LawInterface extends RightsAttributInterface, RelationGrantedInterface, RelationAttributInterface
interface LawInterface extends RightsAttributInterface, RelationGrantedInterface, RelationAttributInterface,MetaInterface
{
}

View File

@ -0,0 +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!
* @author kevinfrantz
*
*/
interface MetaInterface extends EntityInterface
{
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use App\Entity\Attribut\RecieverAttribut;
use Doctrine\Common\Collections\ArrayCollection;
@ -16,7 +16,7 @@ use App\Entity\Attribut\RelationAttributInterface;
* @ORM\Table(name="reciever_group")
* @ORM\Entity()
*/
class RecieverGroup extends AbstractEntity implements RecieverGroupInterface
class RecieverGroup extends AbstractMeta implements RecieverGroupInterface
{
use RelationAttribut,RecieverAttribut;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use App\Entity\Attribut\RecieverAttributInterface;
use Doctrine\Common\Collections\ArrayCollection;
@ -9,7 +9,7 @@ use App\Entity\Attribut\RelationAttributInterface;
/**
* @author kevinfrantz
*/
interface RecieverGroupInterface extends RelationAttributInterface, RecieverAttributInterface
interface RecieverGroupInterface extends RelationAttributInterface, RecieverAttributInterface,MetaInterface
{
public function getAllRecievers(): ArrayCollection;
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\IdAttribut;
@ -21,7 +21,7 @@ use Doctrine\Common\Collections\Collection;
* @ORM\Table(name="node")
* @ORM\Entity()
*/
class Relation extends AbstractEntity implements RelationInterface
class Relation extends AbstractMeta implements RelationInterface
{
use IdAttribut,
SourceAttribut,

View File

@ -1,6 +1,6 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use App\Entity\Attribut\SourceAttributInterface;
use App\Entity\Attribut\IdAttributInterface;
@ -11,6 +11,6 @@ use App\Entity\Attribut\LawAttributInterface;
/**
* @author kevinfrantz
*/
interface RelationInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface, LawAttributInterface
interface RelationInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface, LawAttributInterface,MetaInterface
{
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use App\Entity\Attribut\TypeAttribut;
use Doctrine\ORM\Mapping as ORM;
@ -20,7 +20,7 @@ use App\Entity\Attribut\RelationAttribut;
* @ORM\Table(name="`right`")
* @ORM\Entity(repositoryClass="App\Repository\RightRepository")
*/
class Right extends AbstractEntity implements RightInterface
class Right extends AbstractMeta implements RightInterface
{
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverGroupAttribut,LayerAttribut;

View File

@ -1,6 +1,5 @@
<?php
namespace App\Entity;
namespace App\Entity\Meta;
use App\Entity\Attribut\TypeAttributInterface;
use App\Entity\Attribut\LawAttributInterface;
@ -12,8 +11,9 @@ use App\Entity\Method\RelationGrantedInterface;
use App\Entity\Attribut\RelationAttributInterface;
/**
*
* @author kevinfrantz
*/
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverGroupAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverGroupAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
{
}

View File

@ -2,7 +2,7 @@
namespace App\Entity\Method;
use App\Entity\RelationInterface;
use App\Entity\Meta\RelationInterface;
/**
* @author kevinfrantz

View File

@ -7,9 +7,9 @@ use JMS\Serializer\Annotation\Exclude;
use App\Entity\AbstractEntity;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\Attribut\GroupSourcesAttribut;
use App\Entity\RelationInterface;
use App\Entity\Meta\RelationInterface;
use App\Entity\Attribut\RelationAttribut;
use App\Entity\Relation;
use App\Entity\Meta\Relation;
/**
* @author kevinfrantz
@ -27,7 +27,7 @@ abstract class AbstractSource extends AbstractEntity implements SourceInterface
/**
* @var RelationInterface
* @ORM\OneToOne(targetEntity="App\Entity\Relation",cascade={"persist", "remove"})
* @ORM\OneToOne(targetEntity="App\Entity\Meta\Relation",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
* @Exclude
*/

View File

@ -4,12 +4,13 @@ namespace tests\unit\Entity;
use PHPUnit\Framework\TestCase;
use App\Entity\User;
use App\Entity\Law;
use App\Entity\Meta\Law;
use App\Entity\Meta\Relation;
use App\Entity\Source\UserSource;
use App\Entity\Node;
/**
* @author kevinfrantz
use App\Entity\Source\UserSource;
*/
class UserTest extends TestCase
{
@ -46,7 +47,7 @@ class UserTest extends TestCase
public function testNode(): void
{
$this->assertInstanceOf(Node::class, $this->user->getSource()->getNode());
$this->assertInstanceOf(Relation::class, $this->user->getSource()->getNode());
}
public function testLaw(): void