Exemple #1
0
 /**
  * Notify all observers with an event and the associate object/data that observers might find useful.
  * @param string $event  The event we wish to signal.
  * @param mixed  $object The object/data that we want to make avaliable to the observers.
  */
 public function notify($event, $object)
 {
     $eventObject = new Event($event, $object);
     if (isset($this->_observers[$event]) && is_array($this->_observers[$event])) {
         foreach ($this->_observers[$event] as $observer) {
             if ($eventObject->propagationStopped()) {
                 break;
             }
             $observer->onEvent($eventObject);
         }
     }
 }
Exemple #2
0
 /**
  * @covers Paradox\Event::propagationStopped
  */
 public function testPropagationStopped()
 {
     $this->assertFalse($this->event->propagationStopped(), "The propagation should not be stopped");
     $this->event->stopPropagation();
     $this->assertTrue($this->event->propagationStopped(), "The propagation should be stopped");
 }