mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-04 05:44:58 +00:00
[wip] CRUD
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user