mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized creation process
This commit is contained in:
parent
54615a458e
commit
7c85b98df6
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class LawModificator
|
||||
{
|
||||
public static function grantAllRights(LawInterface $law, NodeInterface $node): void
|
||||
{
|
||||
foreach (LayerType::getChoices() as $layerKey => $layerValue) {
|
||||
foreach (RightType::getChoices() as $rightKey => $rightValue) {
|
||||
$right = new Right();
|
||||
$right->setType($rightKey);
|
||||
$right->setLaw($this);
|
||||
$right->setLayer($layerKey);
|
||||
$right->setNode($node);
|
||||
$law->getRights()->add($right);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -84,6 +84,7 @@ class Right extends AbstractEntity implements RightInterface
|
||||
{
|
||||
parent::__construct();
|
||||
$this->grant = true;
|
||||
$this->recieverGroup = new RecieverGroup();
|
||||
}
|
||||
|
||||
public function isGranted(NodeInterface $node, string $layer, string $right): bool
|
||||
|
@ -7,6 +7,7 @@ use FOS\UserBundle\Model\User as BaseUser;
|
||||
use App\Entity\Attribut\SourceAttributInterface;
|
||||
use App\Entity\Attribut\SourceAttribut;
|
||||
use App\Entity\Attribut\IdAttribut;
|
||||
use App\Creator\Modificator\Entity\LawModificator;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -41,6 +42,6 @@ class User extends BaseUser implements SourceAttributInterface
|
||||
parent::__construct();
|
||||
$this->isActive = true;
|
||||
$this->source = new UserSource();
|
||||
$this->source->setUser($this);
|
||||
LawModificator::grantAllRights($this->source->getNode()->getLaw(), $this->source->getNode());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user