diff --git a/app/config/app.yml b/app/config/app.yml index 398b1cf..a486196 100644 --- a/app/config/app.yml +++ b/app/config/app.yml @@ -1,9 +1,10 @@ application: + modulesDir : ../app/modules/ controllersDir : ../app/controllers/ modelsDir : ../app/models/ migrationsDir : ../app/migrations/ - viewsDir : ../app/views/ + viewsDir : ../app/views/_common/ templateDir : ../app/templates/ listenersDir : ../app/listeners/ libraryDir : ../app/library/ diff --git a/app/config/routes.yml b/app/config/routes.yml index 7b0f625..aba0eda 100644 --- a/app/config/routes.yml +++ b/app/config/routes.yml @@ -56,3 +56,8 @@ router: path: controller: api action: activationlink + + # Backend + backend-home: + pattern: '/admin' + path: backend::user::index diff --git a/app/controllers/backend/UserController.php b/app/controllers/backend/UserController.php new file mode 100644 index 0000000..88a4e4f --- /dev/null +++ b/app/controllers/backend/UserController.php @@ -0,0 +1,10 @@ +setDI($di); + + $this->_app = new Application(); } /** @@ -34,6 +41,14 @@ class Bootstrap extends Injectable $di->get('debugger')->listen(true, true); } + // Modules + $this->_app->registerModules([ + 'main' => [ 'className' => 'App\Module\Main' ], + 'backend' => [ 'className' => 'App\Module\Backend' ], + ]); + + $this->_app->setDefaultModule('main'); + return $this; } @@ -44,7 +59,7 @@ class Bootstrap extends Injectable */ public function run() { - $app = new Application($this->getDI()); - return $app->handle()->getContent(); + $this->_app->setDI($this->getDI()); + return $this->_app->handle()->getContent(); } } diff --git a/app/library/Services.php b/app/library/Services.php index af06def..c6b8ef3 100644 --- a/app/library/Services.php +++ b/app/library/Services.php @@ -99,6 +99,7 @@ class Services extends DiDefault $loader->registerNamespaces(array( 'App\Controller' => $config->application->controllersDir, 'App\Listener' => $config->application->listenersDir, + 'App\Module' => $config->application->modulesDir, 'App\Model' => $config->application->modelsDir, 'App\Form' => $config->application->formsDir, 'Httpcb' => $config->application->libraryDir, @@ -222,7 +223,7 @@ class Services extends DiDefault $view = new View(); - $view->setViewsDir($config->application->viewsDir); + $view->setViewsDir([ $config->application->viewsDir ]); $view->setLayoutsDir('_layouts/'); $view->setPartialsDir('_partials/'); diff --git a/app/modules/Backend.php b/app/modules/Backend.php new file mode 100644 index 0000000..aa1ca6e --- /dev/null +++ b/app/modules/Backend.php @@ -0,0 +1,12 @@ +registerNamespaces([ + $this->_controllerNamespace => $this->_controllerPath, + ]); + + $loader->register(); + } + + /** + * Register specific services for the module + */ + public function registerServices(DiInterface $di) + { + $dispatcher = $di->get('dispatcher'); + + $dispatcher->setDefaultNamespace($this->_controllerNamespace); + + $di->get('view')->setViewsDir(array_merge( + [ $this->_viewDir ], + (array) $di->get('view')->getViewsDir() + )); + } +} + diff --git a/app/modules/Main.php b/app/modules/Main.php new file mode 100644 index 0000000..5e397b0 --- /dev/null +++ b/app/modules/Main.php @@ -0,0 +1,12 @@ +