Horde_Notification_Handler::push PHP Method

push() public method

Add an event to the Horde message stack.
public push ( mixed $event, string $type = null, array $flags = [], array $options = [] )
$event mixed Horde_Notification_Event object or message string.
$type string The type of message.
$flags array Array of optional flags that will be passed to the registered listeners.
$options array Additional options:
'immediate' - (boolean) If true, immediately tries to attach to a
              listener. If no listener exists for this type, the
              message will be dropped.
              DEFAULT: false (message will be attached to available
              handler at the time notify() is called).
    public function push($event, $type = null, array $flags = array(), $options = array())
    {
        if ($event instanceof Horde_Notification_Event) {
            $event->flags = $flags;
            $event->type = $type;
        } else {
            $class = !is_null($type) && ($listener = $this->get($type)) ? $listener->handles($type) : $this->_handles['default']['*'];
            /* Transparently create a Horde_Notification_Event object. */
            $event = new $class($event, $type, $flags);
        }
        foreach ($this->_decorators as $decorator) {
            $decorator->push($event, $options);
        }
        if (!$this->_forceAttach && empty($options['immediate'])) {
            $this->_storage->push('_unattached', $event);
        } else {
            if ($listener = $this->get($event->type)) {
                $this->_storage->push($listener->getName(), $event);
            }
        }
    }

Usage Example

Example #1
0
 /**
  */
 protected function _notify(Horde_Notification_Handler $handler, Horde_Notification_Listener $listener)
 {
     if ($listener instanceof Horde_Notification_Listener_Status && ($ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap'))) {
         /* Display IMAP alerts. */
         foreach ($ob->alerts() as $alert) {
             $handler->push($alert, 'horde.warning');
         }
     }
 }
All Usage Examples Of Horde_Notification_Handler::push