當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。