当前位置: 首页>>代码示例>>PHP>>正文


PHP Zikula_View::getEventManager方法代码示例

本文整理汇总了PHP中Zikula_View::getEventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::getEventManager方法的具体用法?PHP Zikula_View::getEventManager怎么用?PHP Zikula_View::getEventManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zikula_View的用法示例。


在下文中一共展示了Zikula_View::getEventManager方法的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 Zikula_Event($eventName, $eventSubject, $params, $eventData);
    }

    $view->getEventManager()->notify($event);

    // assign results, this plugin does not return any display
    if ($assign) {
        $view->assign($assign, $event->getData());
        return;
    }

    return $event->getData();
}
开发者ID:,项目名称:,代码行数:77,代码来源:


注:本文中的Zikula_View::getEventManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。