diff options
author | Matthieu Aubry <matt@piwik.org> | 2015-02-09 06:26:35 +0300 |
---|---|---|
committer | Matthieu Aubry <matt@piwik.org> | 2015-02-09 06:26:35 +0300 |
commit | e954f84c5cf4e086786849845f58d9342831cd82 (patch) | |
tree | ce959adec6860c63899c3b59d7a80ec7e24a5feb /plugins | |
parent | 6a8228c483e329f6ab7aa7f33fd877dfacf6baef (diff) | |
parent | 5723e93aaeeee34914abc41869c24a1e10476f31 (diff) |
Merge pull request #7124 from piwik/removed-registry
Removed Piwik\Registry and replaced its usage with the container
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Login/Controller.php | 3 | ||||
-rw-r--r-- | plugins/Login/Login.php | 9 | ||||
-rw-r--r-- | plugins/Overlay/API.php | 11 | ||||
-rw-r--r-- | plugins/UsersManager/API.php | 7 | ||||
-rw-r--r-- | plugins/UsersManager/Controller.php | 3 |
5 files changed, 20 insertions, 13 deletions
diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index 1e9c8bc9dd..270b788380 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -13,6 +13,7 @@ use Piwik\Access; use Piwik\Auth as AuthInterface; use Piwik\Common; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\Cookie; use Piwik\Log; use Piwik\Nonce; @@ -60,7 +61,7 @@ class Controller extends \Piwik\Plugin\Controller $this->passwordResetter = $passwordResetter; if (empty($auth)) { - $auth = \Piwik\Registry::get('auth'); + $auth = StaticContainer::get('Piwik\Auth'); } $this->auth = $auth; diff --git a/plugins/Login/Login.php b/plugins/Login/Login.php index 33fd0214d4..ccaa203112 100644 --- a/plugins/Login/Login.php +++ b/plugins/Login/Login.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\Login; use Exception; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\Cookie; use Piwik\FrontController; use Piwik\Option; @@ -65,8 +66,10 @@ class Login extends \Piwik\Plugin */ public function ApiRequestAuthenticate($tokenAuth) { - \Piwik\Registry::get('auth')->setLogin($login = null); - \Piwik\Registry::get('auth')->setTokenAuth($tokenAuth); + /** @var \Piwik\Auth $auth */ + $auth = StaticContainer::get('Piwik\Auth'); + $auth->setLogin($login = null); + $auth->setTokenAuth($tokenAuth); } protected static function isModuleIsAPI() @@ -82,7 +85,7 @@ class Login extends \Piwik\Plugin function initAuthenticationObject($activateCookieAuth = false) { $auth = new Auth(); - \Piwik\Registry::set('auth', $auth); + StaticContainer::getContainer()->set('Piwik\Auth', $auth); $this->initAuthenticationFromCookie($auth, $activateCookieAuth); } diff --git a/plugins/Overlay/API.php b/plugins/Overlay/API.php index 39e16985b1..750697a17f 100644 --- a/plugins/Overlay/API.php +++ b/plugins/Overlay/API.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\Overlay; use Exception; use Piwik\Access; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\DataTable; use Piwik\Piwik; use Piwik\Plugins\SitesManager\API as APISitesManager; @@ -107,16 +108,16 @@ class API extends \Piwik\Plugin\API * Triggered immediately before the user is authenticated. * * This event can be used by plugins that provide their own authentication mechanism - * to make that mechanism available. Subscribers should set the `'auth'` object in - * the {@link Piwik\Registry} to an object that implements the {@link Piwik\Auth} interface. + * to make that mechanism available. Subscribers should set the `'Piwik\Auth'` object in + * the container to an object that implements the {@link Piwik\Auth} interface. * * **Example** * - * use Piwik\Registry; + * use Piwik\Container\StaticContainer; * * public function initAuthenticationObject($activateCookieAuth) * { - * Registry::set('auth', new LDAPAuth($activateCookieAuth)); + * StaticContainer::getContainer()->set('Piwik\Auth', new LDAPAuth($activateCookieAuth)); * } * * @param bool $activateCookieAuth Whether authentication based on `$_COOKIE` values should @@ -124,7 +125,7 @@ class API extends \Piwik\Plugin\API */ Piwik::postEvent('Request.initAuthenticationObject', array($activateCookieAuth = true)); - $auth = \Piwik\Registry::get('auth'); + $auth = StaticContainer::get('Piwik\Auth'); $success = Access::getInstance()->reloadAccess($auth); if (!$success) { diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php index b4be47077a..23ee2206d9 100644 --- a/plugins/UsersManager/API.php +++ b/plugins/UsersManager/API.php @@ -12,6 +12,7 @@ use Exception; use Piwik\Access; use Piwik\Common; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\Date; use Piwik\Option; use Piwik\Piwik; @@ -54,7 +55,7 @@ class API extends \Piwik\Plugin\API * Example of how you would overwrite the UsersManager_API with your own class: * Call the following in your plugin __construct() for example: * - * Registry::set('UsersManager_API', \Piwik\Plugins\MyCustomUsersManager\API::getInstance()); + * StaticContainer::getContainer()->set('UsersManager_API', \Piwik\Plugins\MyCustomUsersManager\API::getInstance()); * * @throws Exception * @return \Piwik\Plugins\UsersManager\API @@ -62,7 +63,7 @@ class API extends \Piwik\Plugin\API public static function getInstance() { try { - $instance = \Piwik\Registry::get('UsersManager_API'); + $instance = StaticContainer::get('UsersManager_API'); if (!($instance instanceof API)) { // Exception is caught below and corrected throw new Exception('UsersManager_API must inherit API'); @@ -71,7 +72,7 @@ class API extends \Piwik\Plugin\API } catch (Exception $e) { self::$instance = new self; - \Piwik\Registry::set('UsersManager_API', self::$instance); + StaticContainer::getContainer()->set('UsersManager_API', self::$instance); } return self::$instance; diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php index 1eb0d93b8f..defb1e4522 100644 --- a/plugins/UsersManager/Controller.php +++ b/plugins/UsersManager/Controller.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\UsersManager; use Exception; use Piwik\API\ResponseBuilder; use Piwik\Common; +use Piwik\Container\StaticContainer; use Piwik\Metrics\Formatter; use Piwik\Piwik; use Piwik\Plugin\ControllerAdmin; @@ -425,7 +426,7 @@ class Controller extends ControllerAdmin // logs the user in with the new password if ($newPassword !== false) { $sessionInitializer = new SessionInitializer(); - $auth = \Piwik\Registry::get('auth'); + $auth = StaticContainer::get('Piwik\Auth'); $auth->setLogin($userLogin); $auth->setPassword($password); $sessionInitializer->initSession($auth, $rememberMe = false); |