chainHandle() публичный Метод

Asks each observer to handle an event based on the provided arguments. The first observer to return a non-null result wins. This is a *very* simplistic implementation of the Chain of Command pattern.
public chainHandle ( string $event, array $args = [] ) : mixed
$event string The event name to handle
$args array The arguments to the event
Результат mixed Null if the event can't be handled by any observer
Пример #1
0
 /**
  * @covers FOF30\Event\Dispatcher::chainHandle
  */
 public function testChainHandle()
 {
     ReflectionHelper::setValue($this->object, 'observers', array());
     ReflectionHelper::setValue($this->object, 'events', array());
     $observer1 = new FirstObserver($this->object);
     $observer2 = new SecondObserver($this->object);
     // Trigger a non-existent event
     $result = $this->object->chainHandle('notthere');
     $this->assertNull($result);
     // Trigger a non-existent event with data
     $result = $this->object->chainHandle('notthere', array('whatever', 'nevermind'));
     $this->assertNull($result);
     // Trigger an event with one observer responding to it
     $result = $this->object->chainHandle('onlySecond');
     $this->assertEquals('only second', $result);
     // Trigger an event with two observers responding to it
     $result = $this->object->chainHandle('identifyYourself');
     $this->assertEquals('one', $result);
     // Trigger an event with two observers responding to it, with parameters
     $result = $this->object->chainHandle('returnConditional', array('one'));
     $this->assertEquals(true, $result);
     // Trigger an event with two observers responding to it, with parameters
     $result = $this->object->chainHandle('returnConditional', array('two'));
     $this->assertEquals(false, $result);
     // Trigger a real chain handler
     $result = $this->object->chainHandle('chain', array('one'));
     $this->assertEquals('one', $result);
     // Trigger a real chain handler
     $result = $this->object->chainHandle('chain', array('two'));
     $this->assertEquals('two', $result);
 }