Webiny\Component\Router\Router::execute PHP Метод

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

public execute ( MatchedRoute $route ) : mixed
$route Webiny\Component\Router\Matcher\MatchedRoute
Результат mixed
    public function execute(MatchedRoute $route)
    {
        $callback = $route->getCallback();
        if ($this->isString($callback)) {
            throw new RouterException(RouterException::STRING_CALLBACK_NOT_PARSABLE);
        }
        $callback = $this->arr($callback);
        $handlerClass = $callback->key('Class', false, true);
        $handlerMethod = $callback->key('Method', false, true);
        $staticMethod = StdObjectWrapper::toBool($callback->key('Static', false, true));
        if (!class_exists($handlerClass)) {
            throw new RouterException(RouterException::CALLBACK_CLASS_NOT_FOUND, [$handlerClass]);
        }
        if (!method_exists($handlerClass, $handlerMethod)) {
            throw new RouterException(RouterException::CALLBACK_CLASS_METHOD_NOT_FOUND, [$handlerMethod, $handlerClass]);
        }
        if ($staticMethod) {
            return forward_static_call_array([$handlerClass, $handlerMethod], $route->getParams());
        }
        return call_user_func_array([new $handlerClass(), $handlerMethod], $route->getParams());
    }