summaryrefslogtreecommitdiff
path: root/plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php
diff options
context:
space:
mode:
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>2010-08-04 16:02:24 -0700
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>2010-08-04 16:02:24 -0700
commitcb34d9519753913138d3831d16687e03d729dabc (patch)
tree04e0c0014d455e398a9a3a9ed514ee250b85ab96 /plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php
parent65a741cce2a02057e858ab4bbf8b5e8ae8c4a73e (diff)
Merge in Phergie changes
Diffstat (limited to 'plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php')
-rwxr-xr-xplugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php43
1 files changed, 32 insertions, 11 deletions
diff --git a/plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php b/plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php
index b2ef089b4..13d2eac8f 100755
--- a/plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php
+++ b/plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php
@@ -69,6 +69,14 @@ class Phergie_Plugin_Handler implements IteratorAggregate, Countable
protected $events;
/**
+ * Iterator used for selectively proxying method calls to contained
+ * plugins
+ *
+ * @var Iterator
+ */
+ protected $iterator;
+
+ /**
* Constructor to initialize class properties and add the path for core
* plugins.
*
@@ -328,7 +336,7 @@ class Phergie_Plugin_Handler implements IteratorAggregate, Countable
$plugins = array();
foreach ($names as $name) {
- $plugins[$name] = $this->getPlugin($name);
+ $plugins[strtolower($name)] = $this->getPlugin($name);
}
return $plugins;
}
@@ -416,26 +424,39 @@ class Phergie_Plugin_Handler implements IteratorAggregate, Countable
*/
public function getIterator()
{
- return new ArrayIterator($this->plugins);
+ if (empty($this->iterator)) {
+ $this->iterator = new Phergie_Plugin_Iterator(
+ new ArrayIterator($this->plugins)
+ );
+ }
+ return $this->iterator;
}
/**
- * Proxies method calls to all plugins containing the called method. An
- * individual plugin may short-circuit this process by explicitly
- * returning FALSE.
+ * Sets the iterator for all currently loaded plugin instances.
+ *
+ * @param Iterator $iterator Plugin iterator
+ *
+ * @return Phergie_Plugin_Handler Provides a fluent interface
+ */
+ public function setIterator(Iterator $iterator)
+ {
+ $this->iterator = $iterator;
+ return $this;
+ }
+
+ /**
+ * Proxies method calls to all plugins containing the called method.
*
* @param string $name Name of the method called
* @param array $args Arguments passed in the method call
*
- * @return bool FALSE if a plugin short-circuits processing by returning
- * FALSE, TRUE otherwise
+ * @return void
*/
public function __call($name, array $args)
{
- foreach ($this->plugins as $plugin) {
- if (call_user_func_array(array($plugin, $name), $args) === false) {
- return false;
- }
+ foreach ($this->getIterator() as $plugin) {
+ call_user_func_array(array($plugin, $name), $args);
}
return true;
}