Exemple #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);
 }
 public function registerEvents()
 {
     EventManager::register('sample.someevent', function ($event) {
         print_r($event->data());
     });
 }