/** * @inheritdoc */ public function dispatch(Event $event) { if (isset($this->listeners[$event->getName()])) { foreach ($this->listeners[$event->getName()] as $listener) { call_user_func($listener, $event); } } }
public function dispatch(Event $event) { if (empty($this->listeners[$event->getName()])) { return; } foreach ($this->listeners[$event->getName()] as $listener) { call_user_func($listener, $event); } }
/** * @param \Event $event */ public static function attach(\Event $event) { if ($event->ready) { if (!isset(self::$events[$event->getName()])) { self::$events[$event->getName()] = []; } if (!is_array(self::$events[$event->getName()])) { self::$events[$event->getName()] = []; } self::$events[$event->getName()][] = $event; } }
/** * @param string|Event $event * @return string */ protected function getEventName($event) { if ($event instanceof Event) { return $event->getName(); } return $event; }
public function apply(Event $event) { $method = 'apply' . $event->getName(); if (method_exists($this, $method)) { $this->{$method}($event); } }
/** * Trigger event * @api * @param string $event * @param string|object $target * @param array|object $params * @return string|object */ public function trigger($event, $target = null, $params = null) { if (!$event instanceof Event) { $event = new Event($event, $target, $params); } if (strstr($event->getName(), ':')) { $namespace = substr($event->getName(), 0, strpos($event->getName(), ':')); if (isset($this->listeners[$namespace])) { $this->fire($this->listeners[$namespace], $event); } } if (isset($this->listeners[$event->getName()])) { $this->fire($this->listeners[$event->getName()], $event); } return $event->getTarget(); }
/** * Filters a value by calling all listeners of a given event. * * @param sfEvent $event A sfEvent instance * @param mixed $value The value to be filtered * * @return sfEvent The sfEvent instance */ public function filter(Event $event, $value) { foreach ($this->getListeners($event->getName()) as $listener) { $value = call_user_func_array($listener, array($event, $value)); } $event->setReturnValue($value); return $event; }
public function fire(Event $event) { $name = $event->getName(); if (!in_array($name, $this->events)) { return; } call_user_func($this->closure, $event); }
/** * @return null */ public function addEvent(Event $event) { $name = $event->getName(); if (!$this->hasEvent($name)) { $this->events[$name] = []; } $this->events[$name][] = $event; }
function encoder_redirect_success(Event $new_Event) { $new_Event_name = $new_Event->getName(); $dir = "VIEW/html/Encoder/Add_Event/Event_List.php?success_edit=1"; $url = BASE_URL . $dir; header("Location:{$url}"); //redirect the encoder to the Events add place exit; }
/** * @covers Panadas\Event\Event::__construct() * @covers Panadas\Event\Event::getName() * @covers Panadas\Event\Event::setName() * @covers Panadas\Event\Event::getPublisher() * @covers Panadas\Event\Event::setPublisher() * @covers Panadas\Event\Event::getParams() * @covers Panadas\Event\Event::setParams() */ public function testConstruct() { $name = "foo"; $publisher = new Publisher(); $params = ["paramkey" => "paramvalue"]; $event = new Event($name, $publisher, $params); $this->assertEquals($name, $event->getName()); $this->assertInstanceOf("Panadas\\Event\\DataStructure\\EventParams", $event->getParams()); $this->assertSame($publisher, $event->getPublisher()); }
private function fireEvent(Event $event) { $listeners = $this->getListeners($event->getName()); if (!$listeners) { return; } foreach ($listeners as $listener) { $listener->handle($event); } }
function encoder_redirect_success(Event $event) { $Name = $event->getName(); $Name_Amharic = $event->getNameAmharic(); $dir = "VIEW/html/Encoder/Add_Event/Add_Events.php?success=1&Name={$Name}&Name_Amharic={$Name_Amharic}"; $url = BASE_URL . $dir; header("Location:{$url}"); //redirect the encoder to the regions add place exit; }
public function broadcast(Event $event) { $name = $event->getName(); if (!isset($this->listeners[$name])) { return; } foreach ($this->listeners[$name] as $listener) { if ($event->isPropagationStopped()) { break; } $listener->fire($event); } }
public function triggerEvent(Event $event) { $eventName = $event->getName(); if (!isset($this->handlers[$eventName])) { return $event; } foreach ($this->handlers[$eventName] as $handler) { $handler->handle($event); if ($event->isCancelled()) { break; } } return $event; }
/** * @param string | Event $event * @param mixed $context * @param mixed $info * @return Event */ public function triggerEvent($event, $context = null, $info = null) { if (!$event instanceof Event) { $event = new Event($event, $context, $info); } $eventName = $event->getName(); if (isset($this->_handlers[$eventName])) { foreach ($this->_handlers[$eventName] as $handler) { $handler->handle($event); if ($event->isCancelled()) { break; } } } return $event; }
/** * Publish an event by calling all listeners that have registered to receive it. * * @param string|EventInterface $event The event name or a EventInterface object * @param array|Traversable $attributes An associative array or a Traversable object * @param ObjectInterface $target The event target * @return null|EventInterface Returns the event object. If the chain is not enabled will return NULL. */ public function publishEvent($event, $attributes = array(), $target = null) { if ($this->isEnabled()) { //Make sure we have an event object if (!$event instanceof EventInterface) { $event = new Event($event, $attributes, $target); } //Notify the listeners $listeners = $this->getListeners($event->getName()); foreach ($listeners as $listener) { $start = microtime(true); call_user_func($listener, $event, $this); $this->__profiles[] = array('message' => $event->getName(), 'period' => microtime(true) - $start, 'time' => microtime(true), 'memory' => $this->getMemoryUsage(), 'target' => $target instanceof ObjectInterface ? $target->getIdentifier() : $target, 'listener' => $listener); if (!$event->canPropagate()) { break; } } return $event; } else { $this->getDelegate()->publishEvent($event, $attributes, $target); } return null; }
/** * Dispatch all listeners of a given event until one returns a non null value. * * @param Event $event A Event instance * * @return Event The Event instance */ public function dispatchUntil($eventName, Event $event) { // skip dispatching because event is already dispatched if ($event->isProcessed()) { return $event; } // skip dispatching because event hasn't listeners if (!$this->hasListeners($eventName)) { return $event; } $event->setName($eventName); foreach ($this->getListeners($event->getName()) as $listener) { if (call_user_func($listener, $event)) { $event->setProcessed(true); break; } } return $event; }
$color=0; foreach ($logs as $entry) { ?> <TR <?php if ($color) { $color=0; ?>class="list_row_even"<?php } else { $color=1; ?>class="list_row_odd"<?php } ?>> <TD ALIGN="CENTER"> <?php p(htmlspecialchars($entry->getTimeStamp())); ?> </TD> <TD> <?php p(htmlspecialchars($entry->getProperty("full_name"))); ?> </TD> <?php if ($f_event_search_id == 0) { ?> <TD> <?php $event = new Event($entry->getEventId(), 1); echo htmlspecialchars($event->getName()); ?> </TD> <?php } ?> <TD> <?php p(htmlspecialchars($entry->getText())); ?> </TD> <TD> <?php p(htmlspecialchars($entry->getClientIP())); ?> </TD> </TR> <?php } ?> </table>
/** * @param Event $event */ public function emit(Event $event) { $event->onEmit(); if ($this->listeners) { if (isset($this->listeners[$event->getName()])) { foreach ($this->listeners[$event->getName()] as $listener) { call_user_func($listener, $event); } } } // call class listeners if ($this->classListeners) { foreach ($this->getParentClasses(get_class($event)) as $class) { if (isset($this->classListeners[$class])) { foreach ($this->classListeners[$class] as $listener) { call_user_func($listener, $event); } } } } }
/** * persist the event until an event handler is listening * * @since 8-25-11 * @param Event $event */ protected function persist(Event $event) { $event_name = $event->getName(); if (!isset($this->persistent_map[$event_name])) { $this->persistent_map[$event_name] = array(); } //if $this->persistent_map[$event_name][] = $event; // keep lists no bigger than 25... if (isset($this->persistent_map[$event_name][$this->persistent_size])) { array_shift($this->persistent_map[$event_name]); } //if }
function json_encode_event(Event $event) { return [$event->getId(), $event->getStartdate(), $event->getEnddate(), $event->getUsers(), $event->getLocation(), $event->getDescription(), $event->getName(), $event->getHosts(), $event->getTags()]; }
/** * @covers Phossa\Event\Event::getName */ public function testGetName() { $this->assertTrue('test' === $this->object->getName()); }
public function testShouldDefineNameOnConstructor() { $name = 'someName'; $event = new Event($name); $this->assertSame($name, $event->getName()); }
/** * triggerEvent * * Usage * <code> * function handler1() { * echo "A"; * } * $event = Koch_Eventdispatcher::instantiate(); * $event->addEventHandler('event_name', 'handler1'); * $event->triggerEvent('event_name'); // Output: A * </code> * * @param $event Name of Event or Event object to trigger. * @param $context default null The context of the event triggering, often the object from where we are calling. * @param $info default null Some pieces of information. * @return $event object */ public function triggerEvent($event, $context = null, $info = null) { /** * init a new event object with constructor settings * if $event is not an instance of Koch_Event. * $event string will be the $name inside $event object, * accessible with $event->getName(); */ if (false === $event instanceof Event) { $event = new Event($event, $context, $info); } // get the Name $eventName = ''; $eventName = $event->getName(); if (isset($this->eventhandlers[$eventName]) === false) { return $event; } // loop over all eventhandlers and look for that eventname foreach ($this->eventhandlers[$eventName] as $eventhandler) { // handle the event !! $eventhandler->execute($event); // break, on cancelled if (method_exists($event, 'isCancelled') and $event->isCancelled() == true) { break; } } return $event; }
/** * {@inheritDoc} */ public function match(Event $event) { return $this->eventName === $event->getName(); }
/** * registers an event in the eventmanagement * * @access public * @static * @param Event $event the event to register */ public static function registerEvent(Event $event) { self::$events[$event->getName()] = $event; }
public function testName() { $event = new Event('eventName'); $this->assertEquals('eventName', $event->getName()); }
public function handle(Event $event) { $authData = $event->getInfo(); $fields = array(date('Y-m-d H:i:s'), $this->_registry->getRequest()->getRemoteAddress(), $event->getName(), $authData['user']); error_log(implode('|', $fields) . "\n", 3, $this->_logFile); }
public function testGetName() { $this->assertEquals('default.test', $this->object->getName()); }