Example #1
0
 public function testEventPriority()
 {
     // lower priority
     $lowPriority = function (Event $event) {
         EventManagerTest::$order[] = 3;
     };
     $highPriority = function (Event $event) {
         EventManagerTest::$order[] = 1;
     };
     $alsoHighPriority = function (Event $event) {
         EventManagerTest::$order[] = 2;
     };
     EventManager::register('test.event1', $lowPriority, EventRegistry::PRIORITY_LOW);
     EventManager::register('test.event1', $highPriority, EventRegistry::PRIORITY_HIGH);
     EventManager::register('test.event1', $alsoHighPriority, EventRegistry::PRIORITY_HIGH);
     $event = new Event('test.event1');
     $event->trigger();
     $this->assertEquals(array(1, 2, 3), static::$order);
 }
Example #2
0
 /**
  * Convenience method for triggering the event from the event object.
  *
  * @param  Zumba\Symbiosis\EventRegistry $registry Single registry instance if used outside of global context.
  * @return boolean
  */
 public function trigger(EventRegistry $registry = null)
 {
     if ($this->pluginContext) {
         return $this->pluginContext->trigger($this);
     }
     return $registry instanceof EventRegistry ? $registry->trigger($this) : EventManager::trigger($this);
 }
Example #3
0
 public function tearDown()
 {
     parent::tearDown();
     EventManager::clearAll();
 }
Example #4
0
 /**
  * Trigger an event to the bound context of this plugin manager.
  *
  * @param Zumba\Symbiosis\Event\Event $event
  * @param array $data
  * @return boolean
  */
 public function trigger(Event $event, $data = array())
 {
     if (!$this->context instanceof EventRegistry) {
         return EventManager::trigger($event, $data);
     }
     return $this->context->trigger($event, $data);
 }
 public function registerEvents()
 {
     EventManager::register('sample.someevent', function ($event) {
         print_r($event->data());
     });
 }