diff --git a/src/Libraries/Module/ModuleManager.php b/src/Libraries/Module/ModuleManager.php index 656007fd..55c544e1 100644 --- a/src/Libraries/Module/ModuleManager.php +++ b/src/Libraries/Module/ModuleManager.php @@ -35,7 +35,7 @@ class ModuleManager /** * @var string */ - private $moduleName; + public static $moduleName; /** * @var string @@ -67,7 +67,7 @@ class ModuleManager */ function __construct(string $moduleName, string $template, string $demo, bool $enabled) { - $this->moduleName = $moduleName; + self::$moduleName = $moduleName; $this->template = $template; @@ -79,7 +79,7 @@ function __construct(string $moduleName, string $template, string $demo, bool $e $this->templatePath = __DIR__ . DS . "Templates" . DS . $type . DS . ucfirst($this->template); - $this->modulePath = modules_dir() . DS . $this->moduleName; + $this->modulePath = modules_dir() . DS . self::$moduleName; $this->fs = Di::get(FileSystem::class); } @@ -107,8 +107,8 @@ public function addModuleConfig() $modules = $this->fs->require($modulesConfigPath); foreach ($modules['modules'] as $module => $options) { - if ($module == $this->moduleName || $options['prefix'] == strtolower($this->moduleName)) { - throw new Exception("A module or prefix named '$this->moduleName' already exists"); + if ($module == self::$moduleName || $options['prefix'] == strtolower(self::$moduleName)) { + throw new Exception("A module or prefix named '" . self::$moduleName . "' already exists"); } } @@ -116,7 +116,7 @@ public function addModuleConfig() $modulesConfigPath, str_replace( "'modules' => [", - $this->writeModuleConfig($this->moduleName), + $this->writeModuleConfig(self::$moduleName), $this->fs->get($modulesConfigPath) ) ); diff --git a/src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php b/src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php index 5e111291..2d03ad47 100644 --- a/src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php +++ b/src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php @@ -1,4 +1,5 @@ moduleName . '\Controllers\Abstracts; +namespace Modules\\' . ModuleManager::$moduleName . '\Controllers\Abstracts; use Quantum\Http\Response; use Quantum\Http\Request; @@ -28,32 +29,32 @@ abstract class OpenApiMainController extends ApiController /** * @OA\Info( - * title="' . $this->moduleName . '", + * title="' . ModuleManager::$moduleName . '", * version="1.0.0", - * description="This is the ' . $this->moduleName . ' module." + * description="This is the ' . ModuleManager::$moduleName . ' module." * ) */ /** * @OA\Tag( - * name="' . $this->moduleName . '", - * description="Operations about the ' . $this->moduleName . '" + * name="' . ModuleManager::$moduleName . '", + * description="Operations about the ' . ModuleManager::$moduleName . '" * ) */ /** * @OA\Get( - * path="/' . strtolower($this->moduleName) . '", - * tags={"' . $this->moduleName . '"}, - * summary="Get status of ' . $this->moduleName . '", - * description="Returns status of ' . $this->moduleName . ' module.", + * path="/' . strtolower(ModuleManager::$moduleName) . '", + * tags={"' . ModuleManager::$moduleName . '"}, + * summary="Get status of ' . ModuleManager::$moduleName . '", + * description="Returns status of ' . ModuleManager::$moduleName . ' module.", * @OA\Response( * response=200, * description="Successful response", * @OA\JsonContent( * type="object", * @OA\Property(property="status", type="string", example="success"), - * @OA\Property(property="message", type="string", example="' . $this->moduleName . ' module.") + * @OA\Property(property="message", type="string", example="' . ModuleManager::$moduleName . ' module.") * ) * ) * ) diff --git a/src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php b/src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php index bf06a543..c91f0e83 100644 --- a/src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php +++ b/src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php @@ -1,8 +1,9 @@ moduleName . '\Controllers; +namespace Modules\\' . ModuleManager::$moduleName . '\Controllers; use Quantum\Factory\ViewFactory; use Quantum\Mvc\QtController; @@ -10,7 +11,7 @@ class MainController extends QtController { - private $name = "' . $this->moduleName . '"; + private $name = "' . ModuleManager::$moduleName . '"; public function index(Response $response) { diff --git a/src/Libraries/Module/Templates/Default/Web/Controllers/MainController.php b/src/Libraries/Module/Templates/Default/Web/Controllers/MainController.php index 8e14bab1..2f7ed358 100644 --- a/src/Libraries/Module/Templates/Default/Web/Controllers/MainController.php +++ b/src/Libraries/Module/Templates/Default/Web/Controllers/MainController.php @@ -1,8 +1,8 @@ moduleName . '\Controllers; +namespace Modules\\' . ModuleManager::$moduleName . '\Controllers; use Quantum\Factory\ViewFactory; use Quantum\Mvc\QtController; diff --git a/src/Libraries/Module/Templates/Default/Web/Views/index.php b/src/Libraries/Module/Templates/Default/Web/Views/index.php index f0188676..3b330eac 100644 --- a/src/Libraries/Module/Templates/Default/Web/Views/index.php +++ b/src/Libraries/Module/Templates/Default/Web/Views/index.php @@ -1,4 +1,5 @@
@@ -6,7 +7,7 @@
<?php echo config()->get(\'app_name\') ?>
-

' . strtoupper($this->moduleName) . ' HOME PAGE

+

' . strtoupper(ModuleManager::$moduleName) . ' HOME PAGE