Ejemplo n.º 1
0
 public function testTrigger()
 {
     $ev = new Event();
     $ev->setData(1, 2);
     $action = function (Event $ev) {
         $data = $ev->getData();
         return [$data[1], $data[0]];
     };
     $this->handler->setAction($action);
     $this->assertEquals([2, 1], $this->handler->trigger($ev));
 }
Ejemplo n.º 2
0
 /**
  * @param string $key
  * @param callable $action
  * @return Handler
  */
 protected static function genHandler($key, $action)
 {
     list($key, $function) = explode('.', $key, 2);
     $handler = new Handler();
     $handler->setKey($key);
     $handler->setFunction($function);
     $handler->setClass(get_called_class());
     $handler->setAction($action);
     return $handler;
 }