initAllRights(); } 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) { if ($right->isGranted($node, $layer, $right)) { return true; } } return false; } }