mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-04-22 19:02:12 +00:00
Changed Modules Handling from json to php
This commit is contained in:
parent
4abe7447bd
commit
05b8625c59
45
modules/ModuleName/ModuleName.php
Normal file
45
modules/ModuleName/ModuleName.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace ModuleName;
|
||||
|
||||
use DeltaCMS\Module\AbstractModule;
|
||||
use DeltaCMS\Module\Config\ConfigInterface;
|
||||
use DeltaCMS\Module\Config\Config;
|
||||
use ModuleName\Controller\ExampleController;
|
||||
|
||||
class ModuleName extends AbstractModule
|
||||
{
|
||||
public function enable(): bool
|
||||
{
|
||||
$this->logger->info(self::class . " has started!");
|
||||
return true;
|
||||
}
|
||||
|
||||
public function update(?ConfigInterface $config = null): ConfigInterface
|
||||
{
|
||||
$config = new Config();
|
||||
$config->setRoutes(array(
|
||||
"example_route" => array(
|
||||
"path" => "/example",
|
||||
"controller" => ExampleController::class,
|
||||
"function" => "index"
|
||||
),
|
||||
"example_route_with_arg" => array(
|
||||
"path" => "/example/{arg}",
|
||||
"controller" => ExampleController::class,
|
||||
"function" => "example",
|
||||
"args" => array(
|
||||
"arg" => array(
|
||||
'regex' => "/[a-z]+/"
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
return $config;
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
$this->logger->info(self::class . "has Disabled");
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
{
|
||||
"routes": {
|
||||
"example_route": {
|
||||
"path": "/example",
|
||||
"controller": "\\ModuleName\\Controller\\ExampleController",
|
||||
"function": "index"
|
||||
},
|
||||
"loggedIn": {
|
||||
"path":"/example/is-logged",
|
||||
"controller":"\\ModuleName\\Controller\\ExampleController",
|
||||
"function": "isLoggedIn"
|
||||
},
|
||||
"example_route_with_arg": {
|
||||
"path": "/example/{arg}",
|
||||
"controller": "\\ModuleName\\Controller\\ExampleController",
|
||||
"function": "example",
|
||||
"args": {
|
||||
"arg": {
|
||||
"regex": "/[a-z]+/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -43,4 +43,6 @@ interface ModuleInterface
|
||||
* @return void
|
||||
*/
|
||||
public function delete();
|
||||
|
||||
public function getName(): string;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user