Optimized layer attribut

This commit is contained in:
Kevin Frantz
2019-01-16 21:47:41 +01:00
parent 6897b44aec
commit 1651ff95f7
4 changed files with 31 additions and 25 deletions

View File

@@ -2,21 +2,37 @@
namespace App\Entity\Attribut;
use App\DBAL\Types\Meta\Right\LayerType;
use App\Exception\NoValidChoiceException;
/**
* @author kevinfrantz
*/
trait LayerAttribut
{
/**
* @see LayerType
*
* @var string
*/
protected $layer;
/**
* @param string $layer
*
* @throws NoValidChoiceException
*/
public function setLayer(string $layer): void
{
if (!array_key_exists($layer, LayerType::getChoices())) {
throw new NoValidChoiceException();
}
$this->layer = $layer;
}
/**
* @return string
*/
public function getLayer(): string
{
return $this->layer;

View File

@@ -6,7 +6,6 @@ use App\Entity\Attribut\CrudAttribut;
use Doctrine\ORM\Mapping as ORM;
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
use App\Entity\Attribut\LawAttribut;
use App\DBAL\Types\Meta\Right\LayerType;
use App\Entity\Attribut\GrantAttribut;
use App\Logic\Operation\OperationInterface;
use App\Entity\Attribut\ConditionAttribut;
@@ -15,8 +14,6 @@ use App\Entity\Attribut\LayerAttribut;
use App\Entity\Attribut\RelationAttribut;
use App\Entity\Attribut\PriorityAttribut;
use App\Entity\Source\SourceInterface;
use App\Exception\NoValidChoiceException;
use App\DBAL\Types\Meta\Right\CRUDType;
/**
* @todo Remove relation attribut!
@@ -98,17 +95,4 @@ class Right extends AbstractMeta implements RightInterface
$this->grant = true;
$this->priority = 0;
}
/**
* {@inheritdoc}
*
* @see \App\Entity\Attribut\LayerAttributInterface::setLayer()
*/
public function setLayer(string $layer): void
{
if (!array_key_exists($layer, LayerType::getChoices())) {
throw new NoValidChoiceException();
}
$this->layer = $layer;
}
}