Implemented Type and Layer validation for right

This commit is contained in:
Kevin Frantz
2018-12-29 16:38:31 +01:00
parent 0aac336609
commit 0c66e7a42a
3 changed files with 43 additions and 3 deletions

View File

@@ -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;
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace App\Exception;
class NoValidChoice extends \Exception
{
}