diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-21 10:08:19 +0400 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-30 01:32:31 +0300 |
commit | c8c787a3574ac6bed2e66fe2588fdafacf990cd2 (patch) | |
tree | feb598d1062e08e5aefa28a997cebd2a9a905404 /core/FrontController.php | |
parent | 10b58b36b8fbc41a1745e051b4bbdce67befa02e (diff) |
The FrontController now uses the container to create controllers (i.e. DI in controllers)
Diffstat (limited to 'core/FrontController.php')
-rw-r--r-- | core/FrontController.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/FrontController.php b/core/FrontController.php index 6f101c10ac..572ecd5744 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -19,7 +19,6 @@ use Piwik\Plugin\Report; use Piwik\Plugin\Widgets; use Piwik\Plugins\CoreAdminHome\CustomLogo; use Piwik\Session; -use Piwik\Plugins\CoreHome\Controller as CoreHomeController; /** * This singleton dispatches requests to the appropriate plugin Controller. @@ -113,6 +112,8 @@ class FrontController extends Singleton protected function makeController($module, $action, &$parameters) { + $container = StaticContainer::getContainer(); + $controllerClassName = $this->getClassNameController($module); // TRY TO FIND ACTION IN CONTROLLER @@ -120,7 +121,7 @@ class FrontController extends Singleton $class = $this->getClassNameController($module); /** @var $controller Controller */ - $controller = new $class; + $controller = $container->get($class); $controllerAction = $action; if ($controllerAction === false) { @@ -146,7 +147,7 @@ class FrontController extends Singleton $parameters['widgetModule'] = $module; $parameters['widgetMethod'] = $action; - return array(new CoreHomeController(), 'renderWidget'); + return array($container->get('Piwik\Plugins\CoreHome\Controller'), 'renderWidget'); } // TRY TO FIND ACTION IN REPORT @@ -157,7 +158,7 @@ class FrontController extends Singleton $parameters['reportModule'] = $module; $parameters['reportAction'] = $action; - return array(new CoreHomeController(), 'renderReportWidget'); + return array($container->get('Piwik\Plugins\CoreHome\Controller'), 'renderReportWidget'); } if (!empty($action) && Report::PREFIX_ACTION_IN_MENU === substr($action, 0, strlen(Report @@ -169,7 +170,7 @@ class FrontController extends Singleton $parameters['reportModule'] = $module; $parameters['reportAction'] = $reportAction; - return array(new CoreHomeController(), 'renderReportMenu'); + return array($container->get('Piwik\Plugins\CoreHome\Controller'), 'renderReportMenu'); } } |