flight\Engine::after PHP Метод

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

Adds a post-filter to a method.
public after ( string $name, callback $callback )
$name string Method name
$callback callback Callback function
    public function after($name, $callback)
    {
        $this->dispatcher->hook($name, 'after', $callback);
    }

Usage Example

Пример #1
0
 function testBeforeAndAfter()
 {
     $this->app->map('hello', function ($name) {
         return "Hello, {$name}!";
     });
     $this->app->before('hello', function (&$params, &$output) {
         // Manipulate the parameter
         $params[0] = 'Fred';
     });
     $this->app->after('hello', function (&$params, &$output) {
         // Manipulate the output
         $output .= " Have a nice day!";
     });
     $result = $this->app->hello('Bob');
     $this->assertEquals('Hello, Fred! Have a nice day!', $result);
 }