本文整理汇总了PHP中Zikula_View::getDispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::getDispatcher方法的具体用法?PHP Zikula_View::getDispatcher怎么用?PHP Zikula_View::getDispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zikula_View
的用法示例。
在下文中一共展示了Zikula_View::getDispatcher方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_notifyevent
/**
* Zikula_View function notify event.
*
* This function notify an event.
*
* Available parameters:
* - 'eventname' The name of the event [required].
* - 'eventsubject' The ID if the subject.
* - 'eventdata' Data.
*
* OR:
* - 'eventobject' An event object [required].
*
* AND:
* - 'assign' If set, the event object's data ($event->getData()) is assigned to the named variable instead displayed [optional].
* - all remaining parameters are passed to the event via the args param in the event.
*
* Example:
* {notifyevent eventname='module.event.name' eventsubject=$subject eventdata=$data arg1=$arg1 arg2=arg2}
* {notifyevent eventname='module.event.name' eventsubject=$subject eventdata=$data arg1=$arg1 arg2=arg2 assign=$data}
* {notifyevent eventname='module.event.name' arg1=$arg1 arg2=arg2 assign=$data}
* {notifyevent eventobject=$eventObject}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see smarty_function_notifyevent()
*
* @return void The results must be assigned to variable in assigned.
*/
function smarty_function_notifyevent($params, Zikula_View $view)
{
if (isset($params['assign'])) {
$assign = $params['assign'];
unset($params['assign']);
} else {
$assign = false;
}
if (isset($params['eventobject'])) {
$event = $params['eventobject'];
unset($params['eventobject']);
} else {
if (isset($params['eventname'])) {
$eventName = $params['eventname'];
unset($params['eventname']);
} else {
return trigger_error(__('eventname is a required param for {notifyevent} plugin.'));
}
if (isset($params['eventsubject'])) {
$eventSubject = $params['eventsubject'];
unset($params['eventsubject']);
} else {
$eventSubject = null;
}
if (isset($params['eventdata'])) {
$eventData = $params['eventdata'];
unset($params['eventdata']);
} else {
$eventData = null;
}
$event = new GenericEvent($eventSubject, $params, $eventData);
}
$view->getDispatcher()->dispatch($eventName, $event);
// assign results, this plugin does not return any display
if ($assign) {
$view->assign($assign, $event->getData());
return;
}
return $event->getData();
}