Skip to content

Commit 9a301ae

Browse files
committed
fix namespace pb with scaffolding
1 parent effd38f commit 9a301ae

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/Ubiquity/scaffolding/creators/AuthControllerCreator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function create(ScaffoldController $scaffoldController) {
3535
} else {
3636
$controllerTemplate = "authController_.tpl";
3737
}
38-
$controllerNS = $this->controllerNS;
3938

4039
$messages = [];
4140
if (isset($this->views)) {
@@ -53,7 +52,7 @@ public function create(ScaffoldController $scaffoldController) {
5352
"%routePath%" => $routePath,
5453
"%route%" => $routeAnnot,
5554
"%uses%" => $this->getUsesStr(),
56-
"%namespace%" => $controllerNS,
55+
"%namespace%" => $this->getNamespaceStr(),
5756
"%baseClass%" => $this->baseClass,
5857
"%content%" => $classContent
5958
], $controllerTemplate);

src/Ubiquity/scaffolding/creators/BaseControllerCreator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public function __construct($controllerName, $routePath, $views,$useViewInherita
4646
$this->controllerNS = Startup::getNS("controllers");
4747
$this->useViewInheritance=$useViewInheritance;
4848
}
49+
50+
protected function getNamespaceStr(){
51+
if($this->controllerNS==null){
52+
return '';
53+
}
54+
return 'namespace '. \trim($this->controllerNS,'\\').';';
55+
}
4956

5057
protected function getRouteAnnotation($path) {
5158
return CacheManager::getAnnotationsEngineInstance()->getAnnotation($this, 'route', [

src/Ubiquity/scaffolding/creators/CrudControllerCreator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public function create(ScaffoldController $scaffoldController) {
3535
$resource = $this->resource;
3636
$crudControllerName = $this->controllerName;
3737
$classContent = '';
38-
$controllerNS = $this->controllerNS;
39-
$nsc=\trim($controllerNS,'\\');
38+
$nsc=\trim($this->controllerNS,'\\');
4039
$messages = [ ];
4140

4241
$scaffoldController->_createMethod ( 'public', '__construct', '', '', "\n\t\tparent::__construct();\n\$this->model=\"{$resource}\";" );
@@ -72,7 +71,7 @@ public function create(ScaffoldController $scaffoldController) {
7271
}
7372

7473
$uses = $this->getUsesStr();
75-
$messages [] = $scaffoldController->_createController ( $crudControllerName, [ '%routePath%' => $routePath,'%route%' => $routeAnnot,'%resource%' => $resource,'%uses%' => $uses,'%namespace%' => $controllerNS,'%baseClass%' => "\\Ubiquity\\controllers\\crud\\CRUDController",'%content%' => $classContent ], $this->templateName );
74+
$messages [] = $scaffoldController->_createController ( $crudControllerName, [ '%routePath%' => $routePath,'%route%' => $routeAnnot,'%resource%' => $resource,'%uses%' => $uses,'%namespace%' => $this->getNamespaceStr(),'%baseClass%' => "\\Ubiquity\\controllers\\crud\\CRUDController",'%content%' => $classContent ], $this->templateName );
7675
echo implode ( "\n", $messages );
7776
}
7877

0 commit comments

Comments
 (0)