Optimized creation process

This commit is contained in:
Kevin Frantz
2018-09-21 16:27:49 +02:00
parent 54615a458e
commit 7c85b98df6
4 changed files with 34 additions and 13 deletions

View File

@@ -5,9 +5,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\RightsAttribute;
use Doctrine\Common\Collections\ArrayCollection;
use App\DBAL\Types\RightType;
use App\Entity\Attribut\NodeAttribut;
use App\DBAL\Types\LayerType;
/**
* @author kevinfrantz
@@ -41,20 +39,12 @@ class Law extends AbstractEntity implements LawInterface
private function initAllRights(): void
{
$this->rights = new ArrayCollection();
foreach (LayerType::getChoices() as $layerKey => $layerValue) {
foreach (RightType::getChoices() as $rightKey => $rightValue) {
$right = new Right();
$right->setType($rightKey);
$right->setLaw($this);
$right->setLayer($layerKey);
$this->rights->add($right);
}
}
}
public function isGranted(NodeInterface $node, string $layer, string $right): bool
{
/**
/*
*
* @var RightInterface
*/
foreach ($this->rights->toArray() as $right) {