示例#1
0
 /**
  *
  */
 public function testAssign()
 {
     $event = new Event('event1');
     $event->setName('event2');
     $this->assertEquals('event2', $event->getName());
     $event->setParams(['param1' => 'value1']);
     $this->assertInstanceOf(Properties::class, $event->getParams());
     $this->assertEquals(['param1' => 'value1'], $event->getParams()->getAll());
 }
示例#2
0
 /**
  * Trigger event with custom params
  * Can be called by passing event model
  *
  * @param string|Event $event
  * @param array        $params
  *
  * @return Event
  */
 public function trigger($event, array $params = [])
 {
     if (!$event instanceof Event) {
         $event = new Event($event, $params);
     }
     if ($listeners = $this->getListeners($event->getName())) {
         $this->dispatch($listeners, $event);
     }
     return $event;
 }