diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-02-02 06:16:08 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-02-02 06:16:08 +0300 |
commit | 344b0fce2ca0e6d5634546b071526c2322bd878f (patch) | |
tree | 40a8a224e2c7ab97d4537cf817fe6f8a817165e4 /plugins/CoreHome | |
parent | 03ea8fb3ec54285bdd63cdada015aa67aec1c6ee (diff) |
Replaced calls of static methods with dependency injection
Diffstat (limited to 'plugins/CoreHome')
-rw-r--r-- | plugins/CoreHome/Controller.php | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/plugins/CoreHome/Controller.php b/plugins/CoreHome/Controller.php index de471d8aa4..7fdfe1d814 100644 --- a/plugins/CoreHome/Controller.php +++ b/plugins/CoreHome/Controller.php @@ -23,6 +23,7 @@ use Piwik\Plugins\CorePluginsAdmin\MarketplaceApiClient; use Piwik\Plugins\Dashboard\DashboardManagerControl; use Piwik\Plugins\UsersManager\API; use Piwik\Site; +use Piwik\Translation\Translator; use Piwik\UpdateCheck; use Piwik\Url; use Piwik\View; @@ -31,7 +32,19 @@ use Piwik\Plugin\Widgets as PluginWidgets; class Controller extends \Piwik\Plugin\Controller { - function getDefaultAction() + /** + * @var Translator + */ + private $translator; + + public function __construct(Translator $translator) + { + $this->translator = $translator; + + parent::__construct(); + } + + public function getDefaultAction() { return 'redirectToCoreHomeIndex'; } @@ -44,7 +57,7 @@ class Controller extends \Piwik\Plugin\Controller $report = Report::factory($reportModule, $reportAction); if (empty($report)) { - throw new Exception(Piwik::translate('General_ExceptionReportNotFound')); + throw new Exception($this->translator->translate('General_ExceptionReportNotFound')); } $report->checkIsEnabled(); @@ -55,7 +68,7 @@ class Controller extends \Piwik\Plugin\Controller throw new Exception('This report is not supposed to be displayed in the menu, please define a $menuTitle in your report.'); } - $menuTitle = Piwik::translate($menuTitle); + $menuTitle = $this->translator->translate($menuTitle); $content = $this->renderReportWidget($reportModule, $reportAction); return View::singleReport($menuTitle, $content); @@ -69,7 +82,7 @@ class Controller extends \Piwik\Plugin\Controller $report = Report::factory($reportModule, $reportAction); if (empty($report)) { - throw new Exception(Piwik::translate('General_ExceptionReportNotFound')); + throw new Exception($this->translator->translate('General_ExceptionReportNotFound')); } $report->checkIsEnabled(); @@ -87,7 +100,7 @@ class Controller extends \Piwik\Plugin\Controller return $widget->$widgetAction(); } - throw new Exception(Piwik::translate('General_ExceptionWidgetNotFound')); + throw new Exception($this->translator->translate('General_ExceptionWidgetNotFound')); } function redirectToCoreHomeIndex() |