[CRUD] check that action exists before inserting them in edit and view template

This commit is contained in:
2020-04-21 12:33:36 +02:00
parent d4b498e2be
commit 1e06393a7d
5 changed files with 25 additions and 2 deletions

View File

@@ -93,4 +93,10 @@ class Resolver
'_'.
$action);
}
public function hasAction($crudName, $action)
{
return \array_key_exists($action,
$this->crudConfig[$crudName]['actions']);
}
}

View File

@@ -47,7 +47,9 @@ class TwigCRUDResolver extends AbstractExtension
{
return [
new TwigFunction('chill_crud_config', [$this, 'getConfig'],
['is_safe' => 'html'])
['is_safe' => 'html']),
new TwigFunction('chill_crud_action_exists', [$this, 'hasAction'],
[]),
];
}
@@ -55,5 +57,10 @@ class TwigCRUDResolver extends AbstractExtension
{
return $this->resolver->getConfigValue($configKey, $crudName, $action);
}
public function hasAction($crudName, $action)
{
return $this->resolver->hasAction($crudName, $action);
}
}