[wip] CRUD

This commit is contained in:
2019-12-03 15:04:39 +01:00
parent 1860a6bae4
commit 257d101fbe
5 changed files with 136 additions and 31 deletions

View File

@@ -51,7 +51,7 @@ class CRUDRoutesLoader
public function load()
{
$collection = new RouteCollection();
foreach ($this->config as $config) {
$collection->addCollection($this->loadConfig($config));
}
@@ -63,23 +63,23 @@ class CRUDRoutesLoader
{
$collection = new RouteCollection();
foreach ($config['actions'] as $action) {
foreach ($config['actions'] as $name => $action) {
$defaults = [
'_controller' => $config['controller'].'::'.$action
'_controller' => $action['controller'] ?? $config['controller'].'::'.$name
];
if ($action === 'index') {
$path = "{_locale}".$config['base_path'];
$route = new Route($path, $defaults);
} else {
$path = "{_locale}".$config['base_path'].'/{id}/'.$action;
$requirements = [
$path = "{_locale}".$config['base_path'].($action['path'] ?? '/{id}/'.$name);
$requirements = $action['requirements'] ?? [
'{id}' => '\d+'
];
$route = new Route($path, $defaults, $requirements);
}
$collection->add('chill_crud_'.$config['name'].'_'.$action, $route);
$collection->add('chill_crud_'.$config['name'].'_'.$name, $route);
}
return $collection;