private function resolveController(string $controllerName, Request $request)
    {
        if (!class_exists($controllerName)) {
            throw new RouteException("Controller class $controllerName does not exist");
        }

        $controller = $this->dependencyResolver->resolve($controllerName);

        if ($controller instanceof Controller) {
            $controller->setRequest($request);

            try {
                $controller->setViewFactory(
                    $this->dependencyResolver->resolve(IViewFactory::class)
                );
            } catch (DependencyResolutionException $ex) {
                // Don't do anything
            }

            try {
                $controller->setViewCompiler(
                    $this->dependencyResolver->resolve(ICompiler::class)
                );
            } catch (DependencyResolutionException $ex) {
                // Don't do anything
            }
        }

        return $controller;
    }
private function resolveController(string $controllerName, Request $request)
    {
        if (!class_exists($controllerName)) {
            throw new RouteException("Controller class $controllerName does not exist");
        }

        $controller = $this->dependencyResolver->resolve($controllerName);

        if ($controller instanceof Controller) {
            $controller->setRequest($request);

            try {
                $controller->setViewFactory(
                    $this->dependencyResolver->resolve(IViewFactory::class)
                );
            } catch (DependencyResolutionException $ex) {
                // Don't do anything
            }

            try {
                $controller->setViewCompiler(
                    $this->dependencyResolver->resolve(ICompiler::class)
                );
            } catch (DependencyResolutionException $ex) {
                // Don't do anything
            }
        }

        return $controller;
    }
private function resolveController ( string $ controllerName , Request $ request ) { if ( ! class_exists ( $ controllerName ) ) { throw new RouteException ( "Controller class $controllerName does not exist" ) ; } $ controller = $ this -> dependencyResolver -> resolve ( $ controllerName ) ; if ( $ controller instanceof Controller ) { $ controller -> setRequest ( $ request ) ; try { $ controller -> setViewFactory ( $ this -> dependencyResolver -> resolve ( IViewFactory :: class ) ) ; } catch ( DependencyResolutionException $ ex ) { // Don't do anything } try { $ controller -> setViewCompiler ( $ this -> dependencyResolver -> resolve ( ICompiler :: class ) ) ; } catch ( DependencyResolutionException $ ex ) { // Don't do anything } } return $ controller ; }
Creates an instance of the input controller

@param string $controllerName The fully-qualified name of the controller class to instantiate
@param Request $request The request that's being routed
@return Controller|mixed The instantiated controller
@throws RouteException Thrown if the controller could not be instantiated
Creates an instance of the input controller