infinito/application/symfony/src/Attribut/CrudAttribut.php

39 lines
625 B
PHP
Raw Normal View History

2019-01-16 21:22:18 +01:00
<?php
2019-01-20 10:41:58 +01:00
namespace App\Attribut;
2019-01-16 21:22:18 +01:00
2019-01-16 21:36:05 +01:00
use App\Exception\NoValidChoiceException;
use App\DBAL\Types\Meta\Right\CRUDType;
2019-01-16 21:22:18 +01:00
/**
* @author kevinfrantz
*/
trait CrudAttribut
{
/**
2019-01-16 21:36:05 +01:00
* @see CRUDType
*
2019-01-16 21:22:18 +01:00
* @var string
*/
protected $crud;
/**
* @param string $crud
*/
public function setCrud(string $crud): void
{
2019-01-16 21:36:05 +01:00
if (!array_key_exists($crud, CRUDType::getChoices())) {
throw new NoValidChoiceException();
}
2019-01-16 21:22:18 +01:00
$this->crud = $crud;
}
/**
* @return string
*/
public function getCrud(): string
{
return $this->crud;
}
}