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:
authormattab <matthieu.aubry@gmail.com>2013-07-21 12:01:35 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-21 12:01:36 +0400
commitaca8ec33a85e0a70b818b6227145041717d7a69e (patch)
tree41377e3a9737d63222522ef93ecf8483f3faddfa /core/EventDispatcher.php
parent0a63210e3eae7562af1a3dbee340eb1ee140db3d (diff)
Refs #4059 Work in progress: Conversion to use Namespaces: Period*, Metrics, Segment, SegmentExpression, PluginsManager.
Removed some deprecated code.
Diffstat (limited to 'core/EventDispatcher.php')
-rw-r--r--core/EventDispatcher.php39
1 files changed, 9 insertions, 30 deletions
diff --git a/core/EventDispatcher.php b/core/EventDispatcher.php
index 8496013cab..7c311e4dd4 100644
--- a/core/EventDispatcher.php
+++ b/core/EventDispatcher.php
@@ -9,11 +9,14 @@
* @package Piwik
*/
+namespace Piwik;
+use Piwik\Plugin;
+
/**
* This class allows code to post events from anywhere in Piwik and for
* plugins to associate callbacks to be executed when events are posted.
*/
-class Piwik_EventDispatcher
+class EventDispatcher
{
// implementation details for postEvent
const EVENT_CALLBACK_GROUP_FIRST = 0;
@@ -31,7 +34,7 @@ class Piwik_EventDispatcher
public static function getInstance()
{
if (self::$instance === null) {
- self::$instance = new Piwik_EventDispatcher();
+ self::$instance = new EventDispatcher();
}
return self::$instance;
}
@@ -66,7 +69,7 @@ class Piwik_EventDispatcher
* loaded after the event is fired.
* @param array|null $plugins The plugins to post events to. If null, the event
* is posted to all plugins. The elements of this array
- * can be either the Piwik_Plugin objects themselves
+ * can be either the Plugin objects themselves
* or their string names.
*/
public function postEvent($eventName, $params, $pending = false, $plugins = null)
@@ -76,7 +79,7 @@ class Piwik_EventDispatcher
}
if (empty($plugins)) {
- $plugins = PluginsManager::getInstance()->getLoadedPlugins();
+ $plugins = \Piwik\PluginsManager::getInstance()->getLoadedPlugins();
}
$callbacks = array();
@@ -84,7 +87,7 @@ class Piwik_EventDispatcher
// collect all callbacks to execute
foreach ($plugins as $plugin) {
if (is_string($plugin)) {
- $plugin = PluginsManager::getInstance()->getLoadedPlugin($plugin);
+ $plugin = \Piwik\PluginsManager::getInstance()->getLoadedPlugin($plugin);
}
$hooks = $plugin->getListHooksRegistered();
@@ -150,7 +153,7 @@ class Piwik_EventDispatcher
/**
* Re-posts all pending events to the given plugin.
*
- * @param Piwik_Plugin $plugin
+ * @param Plugin $plugin
*/
public function postPendingEventsTo($plugin)
{
@@ -182,27 +185,3 @@ class Piwik_EventDispatcher
}
}
-/**
- * Post an event to the dispatcher which will notice the observers.
- *
- * @param string $eventName The event name.
- * @param array $params The parameter array to forward to observer callbacks.
- * @param bool $pending
- * @param null $plugins
- * @return void
- */
-function Piwik_PostEvent($eventName, $params = array(), $pending = false, $plugins = null)
-{
- Piwik_EventDispatcher::getInstance()->postEvent($eventName, $params, $pending, $plugins);
-}
-
-/**
- * Register an action to execute for a given event
- *
- * @param string $eventName Name of event
- * @param callable $function Callback hook
- */
-function Piwik_AddAction($eventName, $function)
-{
- Piwik_EventDispatcher::getInstance()->addObserver($eventName, $function);
-}