Skip to content

Commit 8ab25c4

Browse files
committed
Add default route name for action creation
1 parent 13a62bb commit 8ab25c4

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Ubiquity/scaffolding/ScaffoldController.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* This class is part of Ubiquity
2020
*
2121
* @author jcheron <[email protected]>
22-
* @version 1.0.5
22+
* @version 1.0.6
2323
* @category ubiquity.dev
2424
*
2525
*/
@@ -167,12 +167,13 @@ public function _newAction($controller, $action, $parameters = null, $content =
167167
if ($classCode !== false) {
168168
$fileContent = \implode('', $classCode);
169169
$fileContent = \trim($fileContent);
170+
$ctrlName=ClassUtils::getClassSimpleName($controller);
170171
if ($createView) {
171-
$viewname = $this->_createViewOp(ClassUtils::getClassSimpleName($controller), $action, $theme);
172+
$viewname = $this->_createViewOp($ctrlName, $action, $theme);
172173
$content .= "\n\t\t\$this->loadView('" . $viewname . "');\n";
173174
$msgContent .= "<br>Created view : <b>" . $viewname . "</b>";
174175
}
175-
$routeAnnotation = $this->generateRouteAnnotation($routeInfo);
176+
$routeAnnotation = $this->generateRouteAnnotation($routeInfo,$ctrlName,$action);
176177

177178
if ($routeAnnotation != '') {
178179
$msgContent .= $this->_addMessageForRouteCreation($routeInfo["path"]);
@@ -220,7 +221,12 @@ public function _newAction($controller, $action, $parameters = null, $content =
220221
}
221222
}
222223

223-
protected function generateRouteAnnotation($routeInfo) {
224+
private function generateRouteName(string $controllerName,string $action){
225+
$ctrl=\str_ireplace('controller','',$controllerName);
226+
return \ucfirst($ctrl) . '.' . $action;
227+
}
228+
229+
protected function generateRouteAnnotation($routeInfo,$controllerName,$action) {
224230
if (\is_array($routeInfo)) {
225231
$name = 'route';
226232
$path = $routeInfo['path'];
@@ -244,7 +250,7 @@ protected function generateRouteAnnotation($routeInfo) {
244250
}
245251
}
246252
}
247-
253+
$routeProperties['name']=$this->generateRouteName($controllerName, $action);
248254

249255
return CacheManager::getAnnotationsEngineInstance()->getAnnotation($this,$name,$routeProperties)->asAnnotation();
250256
}

0 commit comments

Comments
 (0)