Questions about the JDispatcher

25 views
Skip to first unread message

TDZWeb

unread,
Jul 24, 2012, 9:50:26 PM7/24/12
to joomla-de...@googlegroups.com
I am putting together a toolbox small libraries and plugins to use for development and I am thinking of making a centralized event management for plugins. However, documentation is very scarce. My central event manager will look something like this:

class myEvent
{
  public static function trigger($name, &$args=array(), $resulthandler = 'self::handle')
  {
    $result = array();
    JPluginHelper::importPlugin('mytoolbox');
    $result = JDispatcher::getInstance()->trigger($name, $args);
    if(is_callable($resulthandler))
    {
      call_user_func($resulthandler, $result);
    }
    return $result;
  }
  public static function handle(&$result)
  {
    foreach($result as $key)
    {
      // do stuff
    }
  }
}

My question is will this work at all? Also, how do I know which plugin returned what result?
Reply all
Reply to author
Forward
0 new messages