コード例 #1
0
ファイル: EventDispatcher.php プロジェクト: angelk/tmp-bships
 /**
  * @inheritdoc
  */
 public function dispatch(Event $event)
 {
     if (isset($this->listeners[$event->getName()])) {
         foreach ($this->listeners[$event->getName()] as $listener) {
             call_user_func($listener, $event);
         }
     }
 }
コード例 #2
0
 public function dispatch(Event $event)
 {
     if (empty($this->listeners[$event->getName()])) {
         return;
     }
     foreach ($this->listeners[$event->getName()] as $listener) {
         call_user_func($listener, $event);
     }
 }
コード例 #3
0
ファイル: EventHandler.php プロジェクト: jankal/mvc
 /**
  * @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;
     }
 }
コード例 #4
0
ファイル: ObserverTrait.php プロジェクト: lytc/sloths
 /**
  * @param string|Event $event
  * @return string
  */
 protected function getEventName($event)
 {
     if ($event instanceof Event) {
         return $event->getName();
     }
     return $event;
 }
コード例 #5
0
 public function apply(Event $event)
 {
     $method = 'apply' . $event->getName();
     if (method_exists($this, $method)) {
         $this->{$method}($event);
     }
 }
コード例 #6
0
ファイル: EventManager.php プロジェクト: 9618211/framework
 /**
  * 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();
 }
コード例 #7
0
ファイル: EventDispatcher.php プロジェクト: nebtrx/stratos
 /**
  * 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;
 }
コード例 #8
0
ファイル: EventListener.php プロジェクト: veloxpro/VeloxPHP
 public function fire(Event $event)
 {
     $name = $event->getName();
     if (!in_array($name, $this->events)) {
         return;
     }
     call_user_func($this->closure, $event);
 }
コード例 #9
0
ファイル: Manager.php プロジェクト: wispira/framework
 /**
  * @return null
  */
 public function addEvent(Event $event)
 {
     $name = $event->getName();
     if (!$this->hasEvent($name)) {
         $this->events[$name] = [];
     }
     $this->events[$name][] = $event;
 }
コード例 #10
0
ファイル: Edit_Event.php プロジェクト: rogermule/afalagi-web
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;
}
コード例 #11
0
ファイル: EventTest.php プロジェクト: panadas/event
 /**
  * @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());
 }
コード例 #12
0
ファイル: Dispatcher.php プロジェクト: sdlyhu/laravelio
 private function fireEvent(Event $event)
 {
     $listeners = $this->getListeners($event->getName());
     if (!$listeners) {
         return;
     }
     foreach ($listeners as $listener) {
         $listener->handle($event);
     }
 }
コード例 #13
0
ファイル: Add_Event.php プロジェクト: rogermule/afalagi-web
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;
}
コード例 #14
0
ファイル: EventManager.php プロジェクト: veloxpro/VeloxPHP
 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);
     }
 }
コード例 #15
0
ファイル: Dispatcher.php プロジェクト: ofeige/opf
 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;
 }
コード例 #16
0
ファイル: EventDispatcher.php プロジェクト: remluben/rsf
 /**
  * @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;
 }
コード例 #17
0
ファイル: profiler.php プロジェクト: nooku/nooku-framework
 /**
  * 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;
 }
コード例 #18
0
 /**
  * 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;
 }
コード例 #19
0
ファイル: index.php プロジェクト: nistormihai/Newscoop
	$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"))); ?>&nbsp;
		</TD>

		<?php if ($f_event_search_id == 0) { ?>
		<TD>
			<?php
			$event = new Event($entry->getEventId(), 1);
			echo htmlspecialchars($event->getName());
			?>&nbsp;
		</TD>
		<?php  } ?>

		<TD>
			<?php  p(htmlspecialchars($entry->getText())); ?>
		</TD>
                <TD>
                        <?php  p(htmlspecialchars($entry->getClientIP())); ?>
                </TD>
	</TR>
<?php
}
?>
</table>
コード例 #20
0
ファイル: Dispatcher.php プロジェクト: cawaphp/cawa
 /**
  * @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);
                 }
             }
         }
     }
 }
コード例 #21
0
ファイル: Dispatch.php プロジェクト: Jaymon/Montage
 /**
  *  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
 }
コード例 #22
0
ファイル: app.php プロジェクト: avelrd/bam
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()];
}
コード例 #23
0
ファイル: EventTest.php プロジェクト: phossa/phossa-event
 /**
  * @covers Phossa\Event\Event::getName
  */
 public function testGetName()
 {
     $this->assertTrue('test' === $this->object->getName());
 }
コード例 #24
0
ファイル: EventTest.php プロジェクト: phpfluent/eventmanager
 public function testShouldDefineNameOnConstructor()
 {
     $name = 'someName';
     $event = new Event($name);
     $this->assertSame($name, $event->getName());
 }
コード例 #25
0
ファイル: Dispatcher.php プロジェクト: Clansuite/Clansuite
 /**
  * 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;
 }
コード例 #26
0
ファイル: NameListener.php プロジェクト: maximebf/events
 /**
  * {@inheritDoc}
  */
 public function match(Event $event)
 {
     return $this->eventName === $event->getName();
 }
コード例 #27
0
 /**
  * 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;
 }
コード例 #28
0
ファイル: EventTest.php プロジェクト: potfur/statemachine
 public function testName()
 {
     $event = new Event('eventName');
     $this->assertEquals('eventName', $event->getName());
 }
コード例 #29
0
ファイル: AuthLoggingHandler.php プロジェクト: remluben/rsf
 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);
 }
コード例 #30
0
 public function testGetName()
 {
     $this->assertEquals('default.test', $this->object->getName());
 }