Changed Modules Handling from json to php

This commit is contained in:
Florian Bouillon 2019-05-07 14:31:27 +02:00
parent 4abe7447bd
commit 05b8625c59
No known key found for this signature in database
GPG Key ID: B143FF27EF555D16
3 changed files with 47 additions and 24 deletions

View 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");
}
}

View File

@ -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]+/"
}
}
}
}
}

View File

@ -43,4 +43,6 @@ interface ModuleInterface
* @return void
*/
public function delete();
public function getName(): string;
}