-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring and cleaning up the library Module
- Loading branch information
Arman
committed
Sep 11, 2024
1 parent
f0fbc44
commit 2f48ce3
Showing
41 changed files
with
503 additions
and
387 deletions.
There are no files selected for viewing
64 changes: 0 additions & 64 deletions
64
src/Libraries/Module/Templates/Default/Api/Controllers/Abstracts/OpenApiMainController.php
This file was deleted.
Oops, something went wrong.
31 changes: 24 additions & 7 deletions
31
src/Libraries/Module/Templates/Default/Api/Controllers/MainController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
<?php | ||
use Quantum\Libraries\Module\ModuleManager; | ||
|
||
return '<?php | ||
namespace Modules\\' . ModuleManager::$moduleName . '\Controllers; | ||
namespace Modules\\' . Quantum\Libraries\Module\ModuleManager::$moduleName . '\Controllers; | ||
use Modules\ApiCustom\Controllers\Abstracts\OpenApiMainController; | ||
use Quantum\Mvc\QtController; | ||
use Quantum\Http\Response; | ||
class MainController extends OpenApiMainController | ||
class MainController extends QtController | ||
{ | ||
private $name = "' . ModuleManager::$moduleName . '"; | ||
/** | ||
* Status error | ||
*/ | ||
const STATUS_ERROR = \'error\'; | ||
/** | ||
* Status success | ||
*/ | ||
const STATUS_SUCCESS = \'success\'; | ||
/** | ||
* CSRF verification | ||
* @var bool | ||
*/ | ||
public $csrfVerification = false; | ||
/** | ||
* Action - success response | ||
* @param Response $response | ||
*/ | ||
public function index(Response $response) | ||
{ | ||
$response->json([ | ||
\'status\' => \'success\', | ||
\'message\' => $this->name . \' module.\' | ||
\'status\' => \'success\', | ||
\'message\' => Quantum\Libraries\Module\ModuleManager::$moduleName . \' module.\' | ||
]); | ||
} | ||
};'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/Libraries/Module/Templates/Default/Api/Controllers/OpenApi/OpenApiMainController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
return '<?php | ||
/** | ||
* Quantum PHP Framework | ||
* | ||
* An open source software development framework for PHP | ||
* | ||
* @package Quantum | ||
* @author Arman Ag. <arman.ag@softberg.org> | ||
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) | ||
* @link http://quantum.softberg.org/ | ||
* @since 2.9.0 | ||
*/ | ||
namespace Modules\\' . Quantum\Libraries\Module\ModuleManager::$moduleName . '\Controllers\OpenApi; | ||
use Quantum\Http\Response; | ||
/** | ||
* Class OpenApiPostController | ||
* @package Modules\Api | ||
*/ | ||
abstract class OpenApiMainController extends OpenApiController | ||
{ | ||
/** | ||
* @OA\Get( | ||
* path="/' . strtolower(Quantum\Libraries\Module\ModuleManager::$moduleName) . '", | ||
* tags={"' . Quantum\Libraries\Module\ModuleManager::$moduleName . '"}, | ||
* summary="Get status of ' . Quantum\Libraries\Module\ModuleManager::$moduleName . '", | ||
* description="Returns status of ' . Quantum\Libraries\Module\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="' . Quantum\Libraries\Module\ModuleManager::$moduleName . ' module.") | ||
* ) | ||
* ) | ||
* ) | ||
*/ | ||
abstract public function index(Response $response); | ||
}'; |
27 changes: 25 additions & 2 deletions
27
src/Libraries/Module/Templates/Default/Web/Controllers/MainController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,44 @@ | ||
<?php | ||
use Quantum\Libraries\Module\ModuleManager; | ||
|
||
return '<?php | ||
namespace Modules\\' . ModuleManager::$moduleName . '\Controllers; | ||
namespace Modules\\' . Quantum\Libraries\Module\ModuleManager::$moduleName . '\Controllers; | ||
use Quantum\Libraries\Asset\Asset; | ||
use Quantum\Factory\ViewFactory; | ||
use Quantum\Mvc\QtController; | ||
use Quantum\Http\Response; | ||
class MainController extends QtController | ||
{ | ||
/** | ||
* Works before an action | ||
* @param ViewFactory $view | ||
*/ | ||
public function __before(ViewFactory $view) | ||
{ | ||
$view->setLayout(static::LAYOUT, [ | ||
new Asset(Asset::CSS, \'css/materialize.min.css\', null, -1, [\'media="screen,projection"\']), | ||
new Asset(Asset::CSS, \'css/custom.css\'), | ||
new Asset(Asset::JS, \'js/jquery-3.7.1.min.js\'), | ||
new Asset(Asset::JS, \'js/materialize.min.js\'), | ||
new Asset(Asset::JS, \'js/custom.js\') | ||
]); | ||
} | ||
/** | ||
* Action - display home page | ||
* @param Response $response | ||
* @param ViewFactory $view | ||
*/ | ||
public function index(Response $response, ViewFactory $view) | ||
{ | ||
$view->setLayout(\'layouts' . DS . 'main\'); | ||
$view->setParams([ | ||
\'title\' => config()->get(\'app_name\'), | ||
]); | ||
$response->html($view->render(\'index\')); | ||
} | ||
};'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.