Skip to content

Commit 7c5337f

Browse files
committed
🔨 improve on createNonModuleController() method to create sub-directory controllers
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent 9a64dfe commit 7c5337f

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

Core/controllers/commands/Create.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ public function createCommand($location = '', $commandName = '', $defaultCommand
941941
return;
942942
}
943943
}
944-
944+
945945
/**
946946
* Create A Non Module Command
947947
*
@@ -1041,7 +1041,15 @@ public function createController($location = '', $controllerName = '', $addContr
10411041
}
10421042
}
10431043

1044-
public function createNonModuleController($controllerName = '', $addController = '', $location = 'App/Controllers')
1044+
/**
1045+
* Create A Non Module Controller
1046+
*
1047+
* @param string $controllerName
1048+
* @param string $addController
1049+
* @param string $location
1050+
* @return void
1051+
*/
1052+
public function createNonModuleController($controllerName = '', $addController = '', $location = 'Controllers')
10451053
{
10461054
$created = '';
10471055

@@ -1051,10 +1059,20 @@ public function createNonModuleController($controllerName = '', $addController =
10511059
if ($addController == '--addcontroller') {
10521060
$controllerName = Inflector::singularize($controllerName) . 'Controller';
10531061
}
1054-
1062+
10551063
$this->controllers = 'Controllers';
1064+
1065+
if ($addController == '--dir' && $location != 'Controllers') {
1066+
$location = str_replace('_', ' ', $location);
1067+
$location = ucwords($location);
1068+
$location = str_replace(' ', '/', $location);
1069+
$this->controllers = 'Controllers' .DS. $location;
1070+
}
1071+
10561072
$controllerDirectory = $this->createAppRootDirectory($this->controllers);
10571073

1074+
$location = 'App/' . $this->controllers;
1075+
10581076
if (file_exists($controllerDirectory . DS . $controllerName . $this->fileExtention)) {
10591077
$this->failureOutput(ucfirst($controllerName). " Controller exists already in the " . $location . " directory");
10601078
return;
@@ -1113,6 +1131,7 @@ public function createNonModuleModel($modelName = '', $modelType = '--easy', $re
11131131
return;
11141132
}
11151133
}
1134+
11161135
/**
11171136
* Create Model
11181137
*

0 commit comments

Comments
 (0)