run() public méthode

Dispatches an event.
public run ( string $name, array $params = [] ) : string
$name string Event name
$params array Callback parameters
Résultat string Output of callback
Exemple #1
0
 function testBeforeAndAfter()
 {
     $this->dispatcher->set('hello', function ($name) {
         return "Hello, {$name}!";
     });
     $this->dispatcher->hook('hello', 'before', function (&$params, &$output) {
         // Manipulate the parameter
         $params[0] = 'Fred';
     });
     $this->dispatcher->hook('hello', 'after', function (&$params, &$output) {
         // Manipulate the output
         $output .= " Have a nice day!";
     });
     $result = $this->dispatcher->run('hello', array('Bob'));
     $this->assertEquals('Hello, Fred! Have a nice day!', $result);
 }