mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Implemented getChoices and getValues from Doctrine ENUM on the right way
This commit is contained in:
@@ -22,7 +22,7 @@ trait ActionTypeAttribut
|
||||
*/
|
||||
public function setActionType(string $actionType): void
|
||||
{
|
||||
if (!array_key_exists($actionType, ActionType::getChoices())) {
|
||||
if (!in_array($actionType, ActionType::getValues())) {
|
||||
throw new NoValidChoiceException('The type is not a valid action type.');
|
||||
}
|
||||
$this->actionType = $actionType;
|
||||
|
@@ -22,7 +22,7 @@ trait CrudAttribut
|
||||
*/
|
||||
public function setCrud(string $crud): void
|
||||
{
|
||||
if (!array_key_exists($crud, CRUDType::getChoices())) {
|
||||
if (!in_array($crud, CRUDType::getValues())) {
|
||||
throw new NoValidChoiceException();
|
||||
}
|
||||
$this->crud = $crud;
|
||||
|
@@ -26,7 +26,7 @@ trait LayerAttribut
|
||||
*/
|
||||
public function setLayer(string $layer): void
|
||||
{
|
||||
if (!array_key_exists($layer, LayerType::getChoices())) {
|
||||
if (!in_array($layer, LayerType::getValues())) {
|
||||
throw new NoValidChoiceException("'$layer' is not a correct layer type.");
|
||||
}
|
||||
$this->layer = $layer;
|
||||
|
@@ -30,8 +30,8 @@ final class LayerType extends AbstractEnumType
|
||||
self::SOURCE => 'source',
|
||||
self::LAW => 'law',
|
||||
self::RIGHT => 'right',
|
||||
self::MEMBER => 'member',
|
||||
self::HEREDITY => 'heredity',
|
||||
self::CREATOR => 'creator',
|
||||
self::MEMBER => 'member relation',
|
||||
self::HEREDITY => 'heredity relation',
|
||||
self::CREATOR => 'creator relation',
|
||||
];
|
||||
}
|
||||
|
@@ -47,8 +47,8 @@ final class RightLayerCombinationService implements RightLayerCombinationService
|
||||
|
||||
private function setCombination(): void
|
||||
{
|
||||
foreach (LayerType::getChoices() as $layer) {
|
||||
foreach (CRUDType::getChoices() as $crud) {
|
||||
foreach (LayerType::getValues() as $layer) {
|
||||
foreach (CRUDType::getValues() as $crud) {
|
||||
if (!array_key_exists($layer, $this->possibleCombinations)) {
|
||||
$this->possibleCombinations[$layer] = [];
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ interface RightLayerCombinationServiceInterface
|
||||
/**
|
||||
* For layer parameter see:.
|
||||
*
|
||||
* @see LayerType::getChoices()
|
||||
* @see LayerType::getValues()
|
||||
*
|
||||
* @param string $layer
|
||||
*
|
||||
@@ -26,7 +26,7 @@ interface RightLayerCombinationServiceInterface
|
||||
/**
|
||||
* For layer parameter see:.
|
||||
*
|
||||
* @see CRUDType::getChoices()
|
||||
* @see CRUDType::getValues()
|
||||
*
|
||||
* @param string $crud
|
||||
*
|
||||
|
@@ -44,7 +44,7 @@ final class ActionTemplateDataStoreService implements ActionTemplateDataStoreSer
|
||||
*/
|
||||
private function isValidActionType(string $actionType): bool
|
||||
{
|
||||
if (in_array($actionType, ActionType::getChoices())) {
|
||||
if (in_array($actionType, ActionType::getValues())) {
|
||||
return true;
|
||||
}
|
||||
throw new NoValidChoiceException("The action type <<$actionType>> is not defined and not valid!");
|
||||
|
Reference in New Issue
Block a user