From 07699f4197d3a92366e4e9c9db6883d8c3209b39 Mon Sep 17 00:00:00 2001 From: Lorenzo Milesi Date: Wed, 24 Oct 2018 08:06:38 +0200 Subject: [PATCH] Allow customization of controller namespace #282 --- CHANGELOG.md | 1 + docs/installation/configuration-options.md | 8 ++++++++ src/User/Bootstrap.php | 4 ++-- src/User/Module.php | 8 ++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 106b506..e940b95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Fix #271: Add closure support for `from` email address; Change default sender to `supportEmail` (bscheshirwork) - Fix #276: Fix missing translatable strings - Enh #249: Show message `email send if possible` any time on reset password request (bscheshirwork) + - Enh #282: Allows customization of controller namespace (maxxer) ## 1.1.4 - February 19, 2018 - Enh: Check enableEmailConfirmation on registration (faenir) diff --git a/docs/installation/configuration-options.md b/docs/installation/configuration-options.md index ba43f70..1ff98c7 100644 --- a/docs/installation/configuration-options.md +++ b/docs/installation/configuration-options.md @@ -162,6 +162,14 @@ protected against brute-force attacks, set it to the highest value that is toler taken to compute the hash doubles for every increment by one of `$blowfishCost`. +#### consoleControllerNamespace (type: `string`, default: `Da\User\Command`) + +Allows customization of the console application controller namespace for the module. + +#### controllerNamespace (type: `string`, default: `Da\User\Controller`) + +Allows customization of the web application controller namespace for the module. + #### classMap (type: `array`, default: `[]`) Configures the definitions of the classes as they have to be override. For more information see diff --git a/src/User/Bootstrap.php b/src/User/Bootstrap.php index 4ad380f..90ca741 100644 --- a/src/User/Bootstrap.php +++ b/src/User/Bootstrap.php @@ -281,7 +281,7 @@ class Bootstrap implements BootstrapInterface */ protected function initConsoleCommands(ConsoleApplication $app) { - $app->getModule('user')->controllerNamespace = 'Da\User\Command'; + $app->getModule('user')->controllerNamespace = $app->getModule('user')->consoleControllerNamespace; } /** @@ -291,7 +291,7 @@ class Bootstrap implements BootstrapInterface */ protected function initControllerNamespace(WebApplication $app) { - $app->getModule('user')->controllerNamespace = 'Da\User\Controller'; + $app->getModule('user')->controllerNamespace = $app->getModule('user')->controllerNamespace; $app->getModule('user')->setViewPath('@Da/User/resources/views'); } diff --git a/src/User/Module.php b/src/User/Module.php index 3c2ab48..e71c65a 100644 --- a/src/User/Module.php +++ b/src/User/Module.php @@ -145,6 +145,14 @@ class Module extends BaseModule * to compute the hash doubles for every increment by one of $cost */ public $blowfishCost = 10; + /** + * @var string Web controller namespace + */ + public $controllerNamespace = 'Da\User\Controller'; + /** + * @var string Console controller namespace + */ + public $consoleControllerNamespace = 'Da\User\Command'; /** * @var array the class map. How the container should load specific classes * @see Bootstrap::buildClassMap() for more details