22 $nsc = \trim($this->controllerNS,
'\\');
24 $domain = DDDManager::getActiveDomain();
25 $initializeContent =
'';
26 $routeNamePrefix =
'';
28 $initializeContent =
"\t\t\Ubiquity\domains\DDDManager::setDomain('" . $domain .
"');";
29 $routeNamePrefix = $domain .
'.';
31 if (($aDb = $this->scaffoldController->getActiveDb()) !=
null) {
32 if ($aDb !==
'default') {
33 $ns = CacheManager::getModelsNamespace($aDb);
34 $routeNamePrefix .= $aDb .
'.';
36 $classContent .=
$scaffoldController->_createMethod(
'protected',
'getModelName',
'',
': string ',
"\t\treturn '" . $ns .
"\\\\'.\ucfirst(\$this->resource);");
37 $classContent .=
$scaffoldController->_createMethod(
'protected',
'getIndexModels',
'',
': array ',
"\t\treturn \Ubiquity\orm\DAO::getModels('" . $aDb .
"');");
38 $initializeContent .=
"\n\t\t\Ubiquity\orm\DAO::start();";
42 if ($routeNamePrefix !=
'') {
43 $classContent .=
$scaffoldController->_createMethod(
'protected',
'getRouteNamePrefix',
'',
': string ',
"\t\treturn '" . $routeNamePrefix .
"';");
45 if ($initializeContent !==
'') {
46 $classContent .=
$scaffoldController->_createMethod(
'public',
'initialize',
'',
'', $initializeContent .
"\n\t\tparent::initialize();");
50 $this->routePath ??=
'{resource}';
57 'name' => $routeNamePrefix .
'crud.index',
62 'name' => $routeNamePrefix .
'crud.home',
65 '%routePath%' =>
'"' . \str_replace(
'{resource}',
'".$this->resource."',
$routePath) .
'"',
66 '%route%' => $routeAnnotation,
69 '%baseClass%' =>
"\\Ubiquity\\controllers\\crud\\MultiResourceCRUDController",
70 '%content%' => $classContent
71 ], $this->templateName);
72 echo \implode(
"\n", $messages);