/** * Dispatch Event * * @param string $eventName * @param array $data (optional) * @return array * */ protected static function _dispatchEvent(&$HandlerObject, $scope, $eventName, $data = array()) { $_this = EventCore::getInstance(); $eventHandlerMethod = $_this->_handlerMethodName($eventName); $return = array(); if (isset($_this->_eventHandlerCache[$eventName])) { foreach ($_this->_eventHandlerCache[$eventName] as $eventClass) { $pluginName = EventCore::_extractPluginName($eventClass); $pluginType = 'loaded'; if (isset($_this->__pluginsMap[$eventName])) { $pluginType = $_this->__pluginsMap[$eventName]; } if (!in_array(Inflector::camelize($pluginName), (array) InfinitasPlugin::listPlugins($pluginType))) { continue; } if ($scope == 'Global' || $scope == $pluginName) { EventCore::_loadEventClass($eventClass); $Event = new Event($eventName, $HandlerObject, $pluginName); $return[$pluginName] = call_user_func_array(array($_this->_eventClasses[$eventClass], $eventHandlerMethod), array($Event, $data)); } } } return $return; }