Skip to content

Commit

Permalink
Merge pull request #144 from Arno2005/master
Browse files Browse the repository at this point in the history
Fixing issue with module name
  • Loading branch information
armanist authored Aug 21, 2024
2 parents 35f477e + 867c56e commit 5915724
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/Libraries/Module/ModuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ModuleManager
/**
* @var string
*/
private $moduleName;
public static $moduleName;

/**
* @var string
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down Expand Up @@ -107,16 +107,16 @@ 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");
}
}

$this->fs->put(
$modulesConfigPath,
str_replace(
"'modules' => [",
$this->writeModuleConfig($this->moduleName),
$this->writeModuleConfig(self::$moduleName),
$this->fs->get($modulesConfigPath)
)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
use Quantum\Libraries\Module\ModuleManager;

return '<?php
Expand All @@ -14,7 +15,7 @@
* @since 2.9.0
*/
namespace Modules\\' . $this->moduleName . '\Controllers\Abstracts;
namespace Modules\\' . ModuleManager::$moduleName . '\Controllers\Abstracts;
use Quantum\Http\Response;
use Quantum\Http\Request;
Expand All @@ -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.")
* )
* )
* )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php
use Quantum\Libraries\Module\ModuleManager;

return '<?php
namespace Modules\\' . $this->moduleName . '\Controllers;
namespace Modules\\' . ModuleManager::$moduleName . '\Controllers;
use Quantum\Factory\ViewFactory;
use Quantum\Mvc\QtController;
use Quantum\Http\Response;
class MainController extends QtController
{
private $name = "' . $this->moduleName . '";
private $name = "' . ModuleManager::$moduleName . '";
public function index(Response $response)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Quantum\Libraries\Module\ModuleManager;
return '<?php
namespace Modules\\' . $this->moduleName . '\Controllers;
namespace Modules\\' . ModuleManager::$moduleName . '\Controllers;
use Quantum\Factory\ViewFactory;
use Quantum\Mvc\QtController;
Expand Down
3 changes: 2 additions & 1 deletion src/Libraries/Module/Templates/Default/Web/Views/index.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
use Quantum\Libraries\Module\ModuleManager;

return '<div class="main-wrapper teal accent-4">
<div class="container wrapper">
<div class="center-align white-text">
<div class="logo-block">
<img src="<?php echo base_url() ?>/assets/images/quantum-logo-white.png" alt="<?php echo config()->get(\'app_name\') ?>" />
</div>
<h1>' . strtoupper($this->moduleName) . ' HOME PAGE</h1>
<h1>' . strtoupper(ModuleManager::$moduleName) . ' HOME PAGE</h1>
</div>
</div>
</div>
Expand Down

0 comments on commit 5915724

Please sign in to comment.