mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-20 11:44:56 +02:00
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity\Meta;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use App\Entity\Attribut\RightsAttribute;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use App\Entity\Attribut\RelationAttribut;
|
|
use App\Entity\Source\SourceInterface;
|
|
|
|
/**
|
|
* @author kevinfrantz
|
|
* @ORM\Table(name="meta_law")
|
|
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
|
|
*/
|
|
final class Law extends AbstractMeta implements LawInterface
|
|
{
|
|
use RightsAttribute, RelationAttribut;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Right", mappedBy="law", cascade={"persist", "remove"})
|
|
*
|
|
* @var ArrayCollection | Right[]
|
|
*/
|
|
protected $rights;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->initAllRights();
|
|
}
|
|
|
|
private function initAllRights(): void
|
|
{
|
|
$this->rights = new ArrayCollection();
|
|
}
|
|
|
|
public function isGranted(SourceInterface $source, string $layer, string $right): bool
|
|
{
|
|
/*
|
|
*
|
|
* @var RightInterface
|
|
*/
|
|
foreach ($this->rights->toArray() as $right) {
|
|
if ($right->isGranted($relation, $layer, $right)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|