VENOM-10: added files x.tpl, x.php Modules
This commit is contained in:
parent
3d92f5347a
commit
f9dd03193e
33 changed files with 975 additions and 35 deletions
78
src/modules/UserModule.php
Normal file
78
src/modules/UserModule.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Modules;
|
||||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
use Venom\Routing\Router;
|
||||
use Venom\Venom;
|
||||
|
||||
class UserModule implements Module, Route
|
||||
{
|
||||
|
||||
public function register(Venom $venom): bool
|
||||
{
|
||||
if (Config::getInstance()->isAdmin()) {
|
||||
$this->registerAdminRoutes($venom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function registerAdminRoutes(Venom $venom)
|
||||
{
|
||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||
'/users' => [
|
||||
'cl' => UserModule::class,
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'routes' => [
|
||||
'*' => [
|
||||
"GET" => 'get',
|
||||
],
|
||||
'1' => [
|
||||
"GET" => 'getById',
|
||||
"POST" => 'update',
|
||||
"PUT" => 'insert',
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'users' => [
|
||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function insert(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue