/**
* Adds an event to the queue.
*
* @param Phergie_Plugin_Abstract $plugin Plugin originating the event
* @param string $type Event type, corresponding to a
* Phergie_Event_Command::TYPE_* constant
* @param array $args Optional event arguments
*
* @return Phergie_Event_Handler Provides a fluent interface
*/
public function addEvent(Phergie_Plugin_Abstract $plugin, $type, array $args = array())
{
if (!defined('Phergie_Event_Command::TYPE_' . strtoupper($type))) {
throw new Phergie_Event_Exception('Unknown event type "' . $type . '"', Phergie_Event_Exception::ERR_UNKNOWN_EVENT_TYPE);
}
$event = new Phergie_Event_Command();
$event->setPlugin($plugin)->setType($type)->setArguments($args);
$this->events[] = $event;
return $this;
}