/** * Removes the listeners for the given event handler. * * @param Enlight_Event_Handler $handler * @return Enlight_Event_EventManager */ public function removeListener(Enlight_Event_Handler $handler) { if (!empty($this->listeners[$handler->getName()])) { $this->listeners[$handler->getName()] = array_diff($this->listeners[$handler->getName()], array($handler)); } return $this; }
/** * The Enlight_Event_Handler_Plugin class constructor expects the event name. * All parameters are set in the internal properties. * * @throws Enlight_Event_Exception * @param string $event * @param Enlight_Plugin_Namespace $namespace * @param Enlight_Plugin_Bootstrap $plugin * @param string $listener * @param integer $position */ public function __construct($event, $namespace = null, $plugin = null, $listener = null, $position = null) { if ($namespace !== null) { $this->setNamespace($namespace); } if ($plugin !== null) { $this->setPlugin($plugin); } if ($listener !== null) { $this->setListener($listener); } parent::__construct($event); $this->setPosition($position); }
/** * The Enlight_Event_Handler_Default class constructor expects the event name, the callback function and * optional the position of the event handler. * * @throws Enlight_Exception * @param string $event * @param callback $listener * @param integer $position */ public function __construct($event, $listener, $position = null) { parent::__construct($event); $this->setListener($listener); $this->setPosition($position); }
/** * Removes the listeners for the given event handler. * * @param Enlight_Event_Handler $handler * * @return Enlight_Event_EventManager */ public function removeListener(Enlight_Event_Handler $handler) { $eventName = strtolower($handler->getName()); if (!empty($this->listeners[$eventName])) { $this->listeners[$eventName] = array_diff($this->listeners[$eventName], array($handler)); } return $this; }