HandlerManager::getNextInvokeHandler PHP Méthode

getNextInvokeHandler() protected méthode

protected getNextInvokeHandler ( Closure $next, $handler )
$next Closure
    protected function getNextInvokeHandler(Closure $next, $handler)
    {
        return function ($name, array &$args, stdClass $context) use($next, $handler) {
            try {
                $array = array($name, &$args, $context, $next);
                $result = call_user_func_array($handler, $array);
                if (class_exists("\\Generator")) {
                    return Future\co($result);
                } else {
                    return Future\toFuture($result);
                }
            } catch (Exception $e) {
                return Future\error($e);
            } catch (Throwable $e) {
                return Future\error($e);
            }
        };
    }

Usage Example

Exemple #1
0
 protected function getNextInvokeHandler(Closure $next, $handler)
 {
     if ($this->async) {
         return parent::getNextInvokeHandler($next, $handler);
     }
     return function ($name, array &$args, stdClass $context) use($next, $handler) {
         $array = array($name, &$args, $context, $next);
         return call_user_func_array($handler, $array);
     };
 }