diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-04-14 05:04:39 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-04-14 05:04:39 +0300 |
commit | 67495d8a03ada1c900c004feefac250cecc233ba (patch) | |
tree | 14012447439496a62ad8b9da643992432ab8a1b6 /plugins/Diagnostics | |
parent | 79b39270f42c20f121ef1f5076cac892a84da25c (diff) |
Use dependency injection in WriteAccessCheck
Diffstat (limited to 'plugins/Diagnostics')
-rw-r--r-- | plugins/Diagnostics/Diagnostic/WriteAccessCheck.php | 35 | ||||
-rw-r--r-- | plugins/Diagnostics/config/config.php | 7 |
2 files changed, 26 insertions, 16 deletions
diff --git a/plugins/Diagnostics/Diagnostic/WriteAccessCheck.php b/plugins/Diagnostics/Diagnostic/WriteAccessCheck.php index 5a291ce4bb..b4e9a4c8b8 100644 --- a/plugins/Diagnostics/Diagnostic/WriteAccessCheck.php +++ b/plugins/Diagnostics/Diagnostic/WriteAccessCheck.php @@ -2,7 +2,6 @@ namespace Piwik\Plugins\Diagnostics\Diagnostic; -use Piwik\Container\StaticContainer; use Piwik\DbHelper; use Piwik\Filechecks; use Piwik\Translation\Translator; @@ -17,9 +16,20 @@ class WriteAccessCheck implements Diagnostic */ private $translator; - public function __construct(Translator $translator) + /** + * Path to the temp directory. + * @var string + */ + private $tmpPath; + + /** + * @param Translator $translator + * @param string $tmpPath Path to the temp directory. + */ + public function __construct(Translator $translator, $tmpPath) { $this->translator = $translator; + $this->tmpPath = $tmpPath; } public function execute() @@ -62,19 +72,16 @@ class WriteAccessCheck implements Diagnostic */ private function getDirectories() { - // TODO dependency injection - $tmpPath = StaticContainer::get('path.tmp'); - $directoriesToCheck = array( - $tmpPath, - $tmpPath . '/assets/', - $tmpPath . '/cache/', - $tmpPath . '/climulti/', - $tmpPath . '/latest/', - $tmpPath . '/logs/', - $tmpPath . '/sessions/', - $tmpPath . '/tcpdf/', - $tmpPath . '/templates_c/', + $this->tmpPath, + $this->tmpPath . '/assets/', + $this->tmpPath . '/cache/', + $this->tmpPath . '/climulti/', + $this->tmpPath . '/latest/', + $this->tmpPath . '/logs/', + $this->tmpPath . '/sessions/', + $this->tmpPath . '/tcpdf/', + $this->tmpPath . '/templates_c/', ); if (! DbHelper::isInstalled()) { diff --git a/plugins/Diagnostics/config/config.php b/plugins/Diagnostics/config/config.php index 1ec0898a55..2214c04a53 100644 --- a/plugins/Diagnostics/config/config.php +++ b/plugins/Diagnostics/config/config.php @@ -27,8 +27,11 @@ return array( ), 'Piwik\Plugins\Diagnostics\DiagnosticService' => DI\object() - ->constructor(DI\link('diagnostics.required'), DI\link('diagnostics.optional')), + ->constructor(DI\link('diagnostics.required'), DI\get('diagnostics.optional')), 'Piwik\Plugins\Diagnostics\Diagnostic\MemoryLimitCheck' => DI\object() - ->constructorParameter('minimumMemoryLimit', DI\link('ini.General.minimum_memory_limit')), + ->constructorParameter('minimumMemoryLimit', DI\get('ini.General.minimum_memory_limit')), + + 'Piwik\Plugins\Diagnostics\Diagnostic\WriteAccessCheck' => DI\object() + ->constructorParameter('tmpPath', DI\get('path.tmp')), ); |