Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2015-03-17 06:14:11 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-03-17 06:14:11 +0300
commitf76ec2495b19c8b33b8f74f6e3e7e8d9be45324a (patch)
treefa2483f6b20a43d3adb3beec18e44546ed16ada5 /plugins
parent42807de32ab64bef2c18eb1f6a6d0a0358f8c57f (diff)
parent3dabc9e1729b0c64240545b22387c4d36c9fbf3c (diff)
Merge pull request #7407 from piwik/di-api
Dependency injection in API classes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/DBStats/API.php13
-rw-r--r--plugins/Dashboard/API.php4
-rw-r--r--plugins/Insights/API.php6
-rw-r--r--plugins/UsersManager/API.php6
4 files changed, 9 insertions, 20 deletions
diff --git a/plugins/DBStats/API.php b/plugins/DBStats/API.php
index 30def6cf79..47417dbc35 100644
--- a/plugins/DBStats/API.php
+++ b/plugins/DBStats/API.php
@@ -13,12 +13,6 @@ use Piwik\DataTable;
use Piwik\Piwik;
/**
- *
- * @see plugins/DBStats/MySQLMetadataProvider.php
- */
-require_once PIWIK_INCLUDE_PATH . '/plugins/DBStats/MySQLMetadataProvider.php';
-
-/**
* DBStats API is used to request the overall status of the Mysql tables in use by Piwik.
* @hideExceptForSuperUser
* @method static \Piwik\Plugins\DBStats\API getInstance()
@@ -30,12 +24,9 @@ class API extends \Piwik\Plugin\API
*/
private $metadataProvider;
- /**
- * Constructor.
- */
- protected function __construct()
+ public function __construct(MySQLMetadataProvider $metadataProvider)
{
- $this->metadataProvider = new MySQLMetadataProvider();
+ $this->metadataProvider = $metadataProvider;
}
/**
diff --git a/plugins/Dashboard/API.php b/plugins/Dashboard/API.php
index d8994c229e..f4637e862a 100644
--- a/plugins/Dashboard/API.php
+++ b/plugins/Dashboard/API.php
@@ -19,9 +19,9 @@ class API extends \Piwik\Plugin\API
{
private $dashboard = null;
- protected function __construct()
+ public function __construct(Dashboard $dashboard)
{
- $this->dashboard = new Dashboard();
+ $this->dashboard = $dashboard;
}
/**
diff --git a/plugins/Insights/API.php b/plugins/Insights/API.php
index 20cb649649..4b3228ffc2 100644
--- a/plugins/Insights/API.php
+++ b/plugins/Insights/API.php
@@ -39,11 +39,9 @@ class API extends \Piwik\Plugin\API
*/
private $model;
- protected function __construct()
+ public function __construct(Model $model)
{
- parent::__construct();
-
- $this->model = new Model();
+ $this->model = $model;
}
private function getOverviewReports()
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index b1c7c227e3..ccb4dac126 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -45,9 +45,9 @@ class API extends \Piwik\Plugin\API
private static $instance = null;
- protected function __construct()
+ public function __construct(Model $model)
{
- $this->model = new Model();
+ $this->model = $model;
}
/**
@@ -71,7 +71,7 @@ class API extends \Piwik\Plugin\API
self::$instance = $instance;
} catch (Exception $e) {
- self::$instance = new self;
+ self::$instance = StaticContainer::get('Piwik\Plugins\UsersManager\API');
StaticContainer::getContainer()->set('UsersManager_API', self::$instance);
}