public function routePathCommand(string $path, string $method = 'GET')
    {
        $server = [
            'REQUEST_URI' => $path,
            'REQUEST_METHOD' => $method
        ];
        $httpRequest = new Request([], [], [], $server);
        $routeContext = new RouteContext($httpRequest, RouteParameters::createEmpty());

        /** @var Route $route */
        foreach ($this->router->getRoutes() as $route) {
            if ($route->matches($routeContext) === true) {
                $routeValues = $route->getMatchResults();

                $this->outputLine('<b>Path:</b>');
                $this->outputLine('  ' . $path);

                $this->outputLine('<b>Route:</b>');
                $this->outputLine('  Name: ' . $route->getName());
                $this->outputLine('  Pattern: ' . $route->getUriPattern());

                $this->outputLine('<b>Result:</b>');
                $this->outputLine('  Package: ' . (isset($routeValues['@package']) ? $routeValues['@package'] : '-'));
                $this->outputLine('  Subpackage: ' . (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : '-'));
                $this->outputLine('  Controller: ' . (isset($routeValues['@controller']) ? $routeValues['@controller'] : '-'));
                $this->outputLine('  Action: ' . (isset($routeValues['@action']) ? $routeValues['@action'] : '-'));
                $this->outputLine('  Format: ' . (isset($routeValues['@format']) ? $routeValues['@format'] : '-'));

                $controllerObjectName = $this->getControllerObjectName($routeValues['@package'], (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : null), $routeValues['@controller']);
                if ($controllerObjectName === null) {
                    $this->outputLine('<b>Controller Error:</b>');
                    $this->outputLine('  !!! No Controller Object found !!!');
                    $this->quit(1);
                }
                $this->outputLine('<b>Controller:</b>');
                $this->outputLine('  ' . $controllerObjectName);
                $this->quit(0);
            }
        }
        $this->outputLine('No matching Route was found');
        $this->quit(1);
    }
public function routePathCommand(string $path, string $method = 'GET')
    {
        $server = [
            'REQUEST_URI' => $path,
            'REQUEST_METHOD' => $method
        ];
        $httpRequest = new Request([], [], [], $server);
        $routeContext = new RouteContext($httpRequest, RouteParameters::createEmpty());

        /** @var Route $route */
        foreach ($this->router->getRoutes() as $route) {
            if ($route->matches($routeContext) === true) {
                $routeValues = $route->getMatchResults();

                $this->outputLine('<b>Path:</b>');
                $this->outputLine('  ' . $path);

                $this->outputLine('<b>Route:</b>');
                $this->outputLine('  Name: ' . $route->getName());
                $this->outputLine('  Pattern: ' . $route->getUriPattern());

                $this->outputLine('<b>Result:</b>');
                $this->outputLine('  Package: ' . (isset($routeValues['@package']) ? $routeValues['@package'] : '-'));
                $this->outputLine('  Subpackage: ' . (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : '-'));
                $this->outputLine('  Controller: ' . (isset($routeValues['@controller']) ? $routeValues['@controller'] : '-'));
                $this->outputLine('  Action: ' . (isset($routeValues['@action']) ? $routeValues['@action'] : '-'));
                $this->outputLine('  Format: ' . (isset($routeValues['@format']) ? $routeValues['@format'] : '-'));

                $controllerObjectName = $this->getControllerObjectName($routeValues['@package'], (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : null), $routeValues['@controller']);
                if ($controllerObjectName === null) {
                    $this->outputLine('<b>Controller Error:</b>');
                    $this->outputLine('  !!! No Controller Object found !!!');
                    $this->quit(1);
                }
                $this->outputLine('<b>Controller:</b>');
                $this->outputLine('  ' . $controllerObjectName);
                $this->quit(0);
            }
        }
        $this->outputLine('No matching Route was found');
        $this->quit(1);
    }
public function routePathCommand ( string $ path , string $ method = 'GET' ) { $ server = [ 'REQUEST_URI' => $ path , 'REQUEST_METHOD' => $ method ] ; $ httpRequest = new Request ( [ ] , [ ] , [ ] , $ server ) ; $ routeContext = new RouteContext ( $ httpRequest , RouteParameters :: createEmpty ( ) ) ; /** @var Route $route */ foreach ( $ this -> router -> getRoutes ( ) as $ route ) { if ( $ route -> matches ( $ routeContext ) === true ) { $ routeValues = $ route -> getMatchResults ( ) ; $ this -> outputLine ( '<b>Path:</b>' ) ; $ this -> outputLine ( '  ' . $ path ) ; $ this -> outputLine ( '<b>Route:</b>' ) ; $ this -> outputLine ( '  Name: ' . $ route -> getName ( ) ) ; $ this -> outputLine ( '  Pattern: ' . $ route -> getUriPattern ( ) ) ; $ this -> outputLine ( '<b>Result:</b>' ) ; $ this -> outputLine ( '  Package: ' . ( isset ( $ routeValues [ '@package' ] ) ? $ routeValues [ '@package' ] : '-' ) ) ; $ this -> outputLine ( '  Subpackage: ' . ( isset ( $ routeValues [ '@subpackage' ] ) ? $ routeValues [ '@subpackage' ] : '-' ) ) ; $ this -> outputLine ( '  Controller: ' . ( isset ( $ routeValues [ '@controller' ] ) ? $ routeValues [ '@controller' ] : '-' ) ) ; $ this -> outputLine ( '  Action: ' . ( isset ( $ routeValues [ '@action' ] ) ? $ routeValues [ '@action' ] : '-' ) ) ; $ this -> outputLine ( '  Format: ' . ( isset ( $ routeValues [ '@format' ] ) ? $ routeValues [ '@format' ] : '-' ) ) ; $ controllerObjectName = $ this -> getControllerObjectName ( $ routeValues [ '@package' ] , ( isset ( $ routeValues [ '@subpackage' ] ) ? $ routeValues [ '@subpackage' ] : null ) , $ routeValues [ '@controller' ] ) ; if ( $ controllerObjectName === null ) { $ this -> outputLine ( '<b>Controller Error:</b>' ) ; $ this -> outputLine ( '  !!! No Controller Object found !!!' ) ; $ this -> quit ( 1 ) ; } $ this -> outputLine ( '<b>Controller:</b>' ) ; $ this -> outputLine ( '  ' . $ controllerObjectName ) ; $ this -> quit ( 0 ) ; } } $ this -> outputLine ( 'No matching Route was found' ) ; $ this -> quit ( 1 ) ; }
Route the given route path

This command takes a given path and displays the detected route and
the selected package, controller and action.

@param string $path The route path to resolve
@param string $method The request method (GET, POST, PUT, DELETE, ...) to simulate
@return void
@throws InvalidRoutePartValueException
@throws StopActionException
Route the given route path