|
|
|
@ -757,33 +757,33 @@ class Engine
|
|
|
|
|
'show' => 'GET /@id',
|
|
|
|
|
'edit' => 'GET /@id/edit',
|
|
|
|
|
'update' => 'PUT /@id',
|
|
|
|
|
'destroy' =>'DELETE /@id'
|
|
|
|
|
'destroy' => 'DELETE /@id'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Create a custom alias base
|
|
|
|
|
$aliasBase = trim(basename($pattern), '/');
|
|
|
|
|
if(isset($options['alias_base']) === true) {
|
|
|
|
|
if (isset($options['alias_base']) === true) {
|
|
|
|
|
$aliasBase = $options['alias_base'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only use these controller methods
|
|
|
|
|
if(isset($options['only']) === true) {
|
|
|
|
|
if (isset($options['only']) === true) {
|
|
|
|
|
$only = $options['only'];
|
|
|
|
|
$defaultMapping = array_filter($defaultMapping, function($key) use ($only) {
|
|
|
|
|
$defaultMapping = array_filter($defaultMapping, function ($key) use ($only) {
|
|
|
|
|
return in_array($key, $only, true) === true;
|
|
|
|
|
}, ARRAY_FILTER_USE_KEY);
|
|
|
|
|
|
|
|
|
|
// Exclude these controller methods
|
|
|
|
|
} else if(isset($options['except']) === true) {
|
|
|
|
|
} elseif (isset($options['except']) === true) {
|
|
|
|
|
$except = $options['except'];
|
|
|
|
|
$defaultMapping = array_filter($defaultMapping, function($key) use ($except) {
|
|
|
|
|
$defaultMapping = array_filter($defaultMapping, function ($key) use ($except) {
|
|
|
|
|
return in_array($key, $except, true) === false;
|
|
|
|
|
}, ARRAY_FILTER_USE_KEY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add group middleware
|
|
|
|
|
$middleware = [];
|
|
|
|
|
if(isset($options['middleware']) === true) {
|
|
|
|
|
if (isset($options['middleware']) === true) {
|
|
|
|
|
$middleware = $options['middleware'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -793,11 +793,12 @@ class Engine
|
|
|
|
|
foreach ($defaultMapping as $controllerMethod => $methodPattern) {
|
|
|
|
|
$router->map(
|
|
|
|
|
$methodPattern,
|
|
|
|
|
$controllerClass.'->'.$controllerMethod
|
|
|
|
|
)->setAlias($aliasBase.'.'.$controllerMethod);
|
|
|
|
|
$controllerClass . '->' . $controllerMethod
|
|
|
|
|
)->setAlias($aliasBase . '.' . $controllerMethod);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
, $middleware);
|
|
|
|
|
},
|
|
|
|
|
$middleware
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|