public function getPathCommand(string $package, string $controller = 'Standard', string $action = 'index', string $format = 'html')
    {
        $packageParts = explode('\\', $package, 2);
        $package = $packageParts[0];
        $subpackage = isset($packageParts[1]) ? $packageParts[1] : null;

        $routeValues = [
            '@package' => $package,
            '@subpackage' => $subpackage,
            '@controller' => $controller,
            '@action' => $action,
            '@format' => $format
        ];

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

        $controllerObjectName = null;
        /** @var $route Route */
        foreach ($this->router->getRoutes() as $route) {
            try {
                $resolves = $route->resolves($routeValues);
                $controllerObjectName = $this->getControllerObjectName($package, $subpackage, $controller);
            } catch (InvalidControllerException $exception) {
                $resolves = false;
            }

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

                $this->outputLine('<b>Generated Path:</b>');
                $this->outputLine('  ' . $route->getResolvedUriConstraints()->getPathConstraint());

                if ($controllerObjectName !== null) {
                    $this->outputLine('<b>Controller:</b>');
                    $this->outputLine('  ' . $controllerObjectName);
                } else {
                    $this->outputLine('<b>Controller Error:</b>');
                    $this->outputLine('  !!! Controller Object was not found !!!');
                }
                return;
            }
        }
        $this->outputLine('<b>No Matching Controller found</b>');
    }
public function getPathCommand(string $package, string $controller = 'Standard', string $action = 'index', string $format = 'html')
    {
        $packageParts = explode('\\', $package, 2);
        $package = $packageParts[0];
        $subpackage = isset($packageParts[1]) ? $packageParts[1] : null;

        $routeValues = [
            '@package' => $package,
            '@subpackage' => $subpackage,
            '@controller' => $controller,
            '@action' => $action,
            '@format' => $format
        ];

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

        $controllerObjectName = null;
        /** @var $route Route */
        foreach ($this->router->getRoutes() as $route) {
            try {
                $resolves = $route->resolves($routeValues);
                $controllerObjectName = $this->getControllerObjectName($package, $subpackage, $controller);
            } catch (InvalidControllerException $exception) {
                $resolves = false;
            }

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

                $this->outputLine('<b>Generated Path:</b>');
                $this->outputLine('  ' . $route->getResolvedUriConstraints()->getPathConstraint());

                if ($controllerObjectName !== null) {
                    $this->outputLine('<b>Controller:</b>');
                    $this->outputLine('  ' . $controllerObjectName);
                } else {
                    $this->outputLine('<b>Controller Error:</b>');
                    $this->outputLine('  !!! Controller Object was not found !!!');
                }
                return;
            }
        }
        $this->outputLine('<b>No Matching Controller found</b>');
    }
public function getPathCommand ( string $ package , string $ controller = 'Standard' , string $ action = 'index' , string $ format = 'html' ) { $ packageParts = explode ( '\\' , $ package , 2 ) ; $ package = $ packageParts [ 0 ] ; $ subpackage = isset ( $ packageParts [ 1 ] ) ? $ packageParts [ 1 ] : null ; $ routeValues = [ '@package' => $ package , '@subpackage' => $ subpackage , '@controller' => $ controller , '@action' => $ action , '@format' => $ format ] ; $ this -> outputLine ( '<b>Resolving:</b>' ) ; $ this -> outputLine ( '  Package: ' . $ routeValues [ '@package' ] ) ; $ this -> outputLine ( '  Subpackage: ' . $ routeValues [ '@subpackage' ] ) ; $ this -> outputLine ( '  Controller: ' . $ routeValues [ '@controller' ] ) ; $ this -> outputLine ( '  Action: ' . $ routeValues [ '@action' ] ) ; $ this -> outputLine ( '  Format: ' . $ routeValues [ '@format' ] ) ; $ controllerObjectName = null ; /** @var $route Route */ foreach ( $ this -> router -> getRoutes ( ) as $ route ) { try { $ resolves = $ route -> resolves ( $ routeValues ) ; $ controllerObjectName = $ this -> getControllerObjectName ( $ package , $ subpackage , $ controller ) ; } catch ( InvalidControllerException $ exception ) { $ resolves = false ; } if ( $ resolves === true ) { $ this -> outputLine ( '<b>Route:</b>' ) ; $ this -> outputLine ( '  Name: ' . $ route -> getName ( ) ) ; $ this -> outputLine ( '  Pattern: ' . $ route -> getUriPattern ( ) ) ; $ this -> outputLine ( '<b>Generated Path:</b>' ) ; $ this -> outputLine ( '  ' . $ route -> getResolvedUriConstraints ( ) -> getPathConstraint ( ) ) ; if ( $ controllerObjectName !== null ) { $ this -> outputLine ( '<b>Controller:</b>' ) ; $ this -> outputLine ( '  ' . $ controllerObjectName ) ; } else { $ this -> outputLine ( '<b>Controller Error:</b>' ) ; $ this -> outputLine ( '  !!! Controller Object was not found !!!' ) ; } return ; } } $ this -> outputLine ( '<b>No Matching Controller found</b>' ) ; }
Generate a route path

This command takes package, controller and action and displays the
generated route path and the selected route:

./flow routing:getPath --format json Acme.Demo\\Sub\\Package

@param string $package Package key and subpackage, subpackage parts are separated with backslashes
@param string $controller Controller name, default is 'Standard'
@param string $action Action name, default is 'index'
@param string $format Requested Format name default is 'html'
@return void
@throws InvalidRoutePartValueException
Generate a route path