Skip to content

Commit

Permalink
Refactoring and cleaning up the library Module
Browse files Browse the repository at this point in the history
  • Loading branch information
Arman committed Sep 11, 2024
1 parent f0fbc44 commit 2f48ce3
Show file tree
Hide file tree
Showing 41 changed files with 503 additions and 387 deletions.

This file was deleted.

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.\'
]);
}
};';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @since 2.9.0
*/
namespace Modules\Api\Controllers\Abstracts;
namespace Modules\\' . Quantum\Libraries\Module\ModuleManager::$moduleName . '\Controllers\OpenApi;
use Quantum\Mvc\QtController;
Expand All @@ -33,24 +33,7 @@
* in="header"
* )
*/
abstract class ApiController extends QtController
abstract class OpenApiController
{
/**
* Status error
*/
const STATUS_ERROR = \'error\';
/**
* Status success
*/
const STATUS_SUCCESS = \'success\';
/**
* CSRF verification
* @var bool
*/
public $csrfVerification = false;
}
';
}';
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);
}';
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\'));
}
};';
2 changes: 1 addition & 1 deletion src/Libraries/Module/Templates/Default/Web/Views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
</div>
</div>
</div>
<?php echo partial(\'partials' . DS . 'bubbles\') ?>';
<?php echo partial(\'partials/bubbles\') ?>';
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="shortcut icon" href="<?php echo asset()->url(\'images/favicon.ico\') ?>">
<link rel=\'stylesheet\' href=\'<?php echo asset()->url(\'css/materialize.min.css\') ?>\' type=\'text/css\' media=\'screen,projection\' />
<link rel=\'stylesheet\' href=\'<?php echo asset()->url(\'css/custom.css\') ?>\' type=\'text/css\' />
<?php assets("css") ?>
</head>
<body>
<main><?php echo view() ?></main>
<?php echo debugbar() ?>
<script type=\'text/javascript\' src=\'<?php echo asset()->url(\'js/materialize.min.js\') ?>\'></script>
<script type=\'text/javascript\' src=\'<?php echo asset()->url(\'js/custom.js\') ?>\'></script>
<?php assets("js") ?>
</body>
</html>';
23 changes: 11 additions & 12 deletions src/Libraries/Module/Templates/Demo/Api/Config/auth.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return '<?php
return "<?php
return [
/**
Expand All @@ -11,15 +11,14 @@
* Type identifies Auth class to use and can be one of these values: web or api
* Service identifies the Auth service to use
*/
\'type\' => \'api\',
\'service\' => Shared\Services\AuthService::class,
\'claims\' => [
\'jti\' => uniqid(),
\'iss\' => \'issuer\',
\'aud\' => \'audience\',
\'iat\' => time(),
\'nbf\' => time() + 1,
\'exp\' => time() + 3600 // 1 hour
'type' => 'api',
'service' => SharedServicesAuthService::class,
'claims' => [
'jti' => uniqid(),
'iss' => 'issuer',
'aud' => 'audience',
'iat' => time(),
'nbf' => time() + 1,
'exp' => time() + 3600 // 1 hour
]
];
';
];";
13 changes: 6 additions & 7 deletions src/Libraries/Module/Templates/Demo/Api/Config/cors.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return '<?php
return "<?php
return [
/**
Expand All @@ -9,9 +9,8 @@
* ---------------------------------------------------------
* Settings defined here determines the cross-origin resource sharing
*/
\'Access-Control-Allow-Origin\' => \'*\',
\'Access-Control-Allow-Headers\' => \'Origin, X-Requested-With, Content-Type, Accept, Authorization, refresh_token\',
\'Access-Control-Allow-Methods\' => \'GET, POST, PUT, DELETE, OPTIONS\',
\'Access-Control-Allow-Credentials\' => true,
];
';
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Headers' => 'Origin, X-Requested-With, Content-Type, Accept, Authorization, refresh_token',
'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Credentials' => true,
];";
Loading

0 comments on commit 2f48ce3

Please sign in to comment.