mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Implemented Type and Layer validation for right
This commit is contained in:
@@ -16,6 +16,7 @@ use App\Entity\Attribut\LayerAttribut;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Attribut\PriorityAttribut;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Exception\NoValidChoice;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -95,4 +96,20 @@ class Right extends AbstractMeta implements RightInterface
|
||||
$this->grant = true;
|
||||
$this->priority = 0;
|
||||
}
|
||||
|
||||
public function setType(string $type): void
|
||||
{
|
||||
if (!array_key_exists($type, RightType::getChoices())) {
|
||||
throw new NoValidChoice();
|
||||
}
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setLayer(string $layer): void
|
||||
{
|
||||
if (!array_key_exists($layer, LayerType::getChoices())) {
|
||||
throw new NoValidChoice();
|
||||
}
|
||||
$this->layer = $layer;
|
||||
}
|
||||
}
|
||||
|
7
application/src/Exception/NoValidChoice.php
Normal file
7
application/src/Exception/NoValidChoice.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
class NoValidChoice extends \Exception
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user