Skip to content

Commit

Permalink
Fixing issue with module name
Browse files Browse the repository at this point in the history
  • Loading branch information
Arno2005 committed Aug 21, 2024
1 parent 35f477e commit 867c56e
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;

Check warning on line 70 in src/Libraries/Module/ModuleManager.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/ModuleManager.php#L70

Added line #L70 was not covered by tests

$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;

Check warning on line 82 in src/Libraries/Module/ModuleManager.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/ModuleManager.php#L82

Added line #L82 was not covered by tests

$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");

Check warning on line 111 in src/Libraries/Module/ModuleManager.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/ModuleManager.php#L110-L111

Added lines #L110 - L111 were not covered by tests
}
}

$this->fs->put(
$modulesConfigPath,
str_replace(
"'modules' => [",
$this->writeModuleConfig($this->moduleName),
$this->writeModuleConfig(self::$moduleName),

Check warning on line 119 in src/Libraries/Module/ModuleManager.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/ModuleManager.php#L119

Added line #L119 was not covered by tests
$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;

Check warning on line 18 in src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php#L18

Added line #L18 was not covered by tests
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 . '",

Check warning on line 32 in src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php#L32

Added line #L32 was not covered by tests
* version="1.0.0",
* description="This is the ' . $this->moduleName . ' module."
* description="This is the ' . ModuleManager::$moduleName . ' module."

Check warning on line 34 in src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php#L34

Added line #L34 was not covered by tests
* )
*/
/**
* @OA\Tag(
* name="' . $this->moduleName . '",
* description="Operations about the ' . $this->moduleName . '"
* name="' . ModuleManager::$moduleName . '",
* description="Operations about the ' . ModuleManager::$moduleName . '"

Check warning on line 41 in src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php#L40-L41

Added lines #L40 - L41 were not covered by tests
* )
*/
/**
* @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.",

Check warning on line 50 in src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php#L47-L50

Added lines #L47 - L50 were not covered by tests
* @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.")

Check warning on line 57 in src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php#L57

Added line #L57 was not covered by tests
* )
* )
* )
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;

Check warning on line 6 in src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php#L6

Added line #L6 was not covered by tests
use Quantum\Factory\ViewFactory;
use Quantum\Mvc\QtController;
use Quantum\Http\Response;
class MainController extends QtController
{
private $name = "' . $this->moduleName . '";
private $name = "' . ModuleManager::$moduleName . '";

Check warning on line 14 in src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php#L14

Added line #L14 was not covered by tests
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;

Check warning on line 5 in src/Libraries/Module/Templates/Default/Web/Controllers/MainController.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Web/Controllers/MainController.php#L5

Added line #L5 was not covered by tests
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>

Check warning on line 10 in src/Libraries/Module/Templates/Default/Web/Views/index.php

View check run for this annotation

Codecov / codecov/patch

src/Libraries/Module/Templates/Default/Web/Views/index.php#L10

Added line #L10 was not covered by tests
</div>
</div>
</div>
Expand Down

0 comments on commit 867c56e

Please sign in to comment.