Event_Dispatcher::postNotification PHP Method

postNotification() public method

Posts the {@link Event_Notification} object
See also: Event_Dispatcher::post()
public postNotification ( &$notification, $pending = true, $bubble = true ) : object
return object The notification object
    function &postNotification(&$notification, $pending = true, $bubble = true)
    {
        $nName = $notification->getNotificationName();
        if ($pending === true) {
            $this->_pending[$nName][] =& $notification;
        }
        $objClass = get_class($notification->getNotificationObject());
        // Find the registered observers
        if (isset($this->_ro[$nName])) {
            foreach (array_keys($this->_ro[$nName]) as $k) {
                $rObserver =& $this->_ro[$nName][$k];
                if ($notification->isNotificationCancelled()) {
                    return $notification;
                }
                if (empty($rObserver['class']) || strcasecmp($rObserver['class'], $objClass) == 0) {
                    call_user_func_array($rObserver['callback'], array(&$notification));
                    $notification->increaseNotificationCount();
                }
            }
        }
        // Notify globally registered observers
        if (isset($this->_ro[EVENT_DISPATCHER_GLOBAL])) {
            foreach (array_keys($this->_ro[EVENT_DISPATCHER_GLOBAL]) as $k) {
                $rObserver =& $this->_ro[EVENT_DISPATCHER_GLOBAL][$k];
                if ($notification->isNotificationCancelled()) {
                    return $notification;
                }
                if (empty($rObserver['class']) || strcasecmp($rObserver['class'], $objClass) == 0) {
                    call_user_func_array($rObserver['callback'], array(&$notification));
                    $notification->increaseNotificationCount();
                }
            }
        }
        if ($bubble === false) {
            return $notification;
        }
        // Notify in nested dispatchers
        foreach (array_keys($this->_nestedDispatchers) as $nested) {
            $notification =& $this->_nestedDispatchers[$nested]->postNotification($notification, $pending);
        }
        return $notification;
    }