class RoutingCommandController extends CommandController (View source)

Command controller for tasks related to routing

Properties

protected Request $request from  CommandController
protected Response $response from  CommandController
protected Arguments $arguments from  CommandController
protected string $commandMethodName

Name of the command method

from  CommandController
protected ObjectManagerInterface $objectManager
protected CommandManager $commandManager from  CommandController
protected ConsoleOutput $output from  CommandController
protected RoutesProviderInterface $routesProvider
protected ServerRequestFactory $serverRequestFactory

Methods

__construct()

Constructs the command controller

void
injectCommandManager(CommandManager $commandManager)

No description

void
injectObjectManager(ObjectManagerInterface $objectManager)

Injects the reflection service

void
processRequest(Request $request, Response $response)

Processes a command line request.

string
resolveCommandMethodName()

Resolves and checks the current command method name

void
initializeCommandMethodArguments()

Initializes the arguments array of this controller by creating an empty argument object for each of the method arguments found in the designated command method.

void
mapRequestArgumentsToControllerArguments()

Maps arguments delivered by the request object to the local controller arguments.

void
forward(string $commandName, string $controllerObjectName = null, array $arguments = [])

Forwards the request to another command and / or CommandController.

void
callCommandMethod()

Calls the specified command method and passes the arguments.

string
getFlowInvocationString()

Returns the CLI Flow command depending on the environment

void
output(string $text, array $arguments = [])

Outputs specified text to the console window You can specify arguments that will be passed to the text via sprintf

void
outputLine(string $text = '', array $arguments = [])

Outputs specified text to the console window and appends a line break

void
outputFormatted(string $text = '', array $arguments = [], int $leftPadding = 0)

Formats the given text to fit into MAXIMUM_LINE_LENGTH and outputs it to the console window

never
quit(int $exitCode = 0)

Exits the CLI through the dispatcher and makes sure that Flow is properly shut down.

never
sendAndExit(int $exitCode = 0)

Sends the response and exits the CLI without any further code execution Should be used for commands that flush code caches.

void
listCommand()

List the known routes

void
showCommand(int $index)

Show information for a route

void
getPathCommand(string $package, string $controller = 'Standard', string $action = 'index', string $format = 'html') deprecated

Generate a route path

void
resolveCommand(string $package, string $controller = null, string $action = null, string $format = null, string $subpackage = null, string $additionalArguments = null, string $parameters = null, string $baseUri = null, bool $forceAbsoluteUri = null)

Build an URI for the given parameters

void
routePathCommand(string $path, string $method = 'GET') deprecated

Route the given route path

void
matchCommand(string $uri, string $method = null, string $parameters = null)

Match the given URI to a corresponding route

Details

__construct()

Constructs the command controller

void injectCommandManager(CommandManager $commandManager)

No description

Parameters

CommandManager $commandManager

Return Value

void

void injectObjectManager(ObjectManagerInterface $objectManager)

Injects the reflection service

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void processRequest(Request $request, Response $response)

Processes a command line request.

Parameters

Request $request

The request object

Response $response

The response, modified by the controller

Return Value

void

Exceptions

InvalidArgumentTypeException
NoSuchCommandException

protected string resolveCommandMethodName()

Resolves and checks the current command method name

Note: The resulting command method name might not have the correct case, which isn't a problem because PHP is case insensitive regarding method names.

Return Value

string

Method name of the current command

Exceptions

NoSuchCommandException

protected void initializeCommandMethodArguments()

Initializes the arguments array of this controller by creating an empty argument object for each of the method arguments found in the designated command method.

Return Value

void

Exceptions

InvalidArgumentTypeException

protected void mapRequestArgumentsToControllerArguments()

Maps arguments delivered by the request object to the local controller arguments.

Return Value

void

protected void forward(string $commandName, string $controllerObjectName = null, array $arguments = [])

Forwards the request to another command and / or CommandController.

Request is directly transferred to the other command / controller without the need for a new request.

Parameters

string $commandName
string $controllerObjectName
array $arguments

Return Value

void

Exceptions

StopCommandException

protected void callCommandMethod()

Calls the specified command method and passes the arguments.

If the command returns a string, it is appended to the content in the response object. If the command doesn't return anything and a valid view exists, the view is rendered automatically.

Return Value

void

string getFlowInvocationString()

Returns the CLI Flow command depending on the environment

Return Value

string

protected void output(string $text, array $arguments = [])

Outputs specified text to the console window You can specify arguments that will be passed to the text via sprintf

Parameters

string $text

Text to output

array $arguments

Optional arguments to use for sprintf

Return Value

void

See also

http://www.php.net/sprintf

protected void outputLine(string $text = '', array $arguments = [])

Outputs specified text to the console window and appends a line break

Parameters

string $text

Text to output

array $arguments

Optional arguments to use for sprintf

Return Value

void

See also

output()
outputLines()

protected void outputFormatted(string $text = '', array $arguments = [], int $leftPadding = 0)

Formats the given text to fit into MAXIMUM_LINE_LENGTH and outputs it to the console window

Parameters

string $text

Text to output

array $arguments

Optional arguments to use for sprintf

int $leftPadding

The number of spaces to use for indentation

Return Value

void

See also

outputLine()

protected never quit(int $exitCode = 0)

Exits the CLI through the dispatcher and makes sure that Flow is properly shut down.

If your command relies on functionality which is triggered through the Bootstrap shutdown (such as the persistence framework), you must use quit() instead of exit().

Parameters

int $exitCode

Exit code to return on exit (see http://www.php.net/exit)

Return Value

never

Exceptions

StopCommandException

protected never sendAndExit(int $exitCode = 0)

Sends the response and exits the CLI without any further code execution Should be used for commands that flush code caches.

Parameters

int $exitCode

Exit code to return on exit

Return Value

never

void listCommand()

List the known routes

This command displays a list of all currently registered routes.

Return Value

void

void showCommand(int $index)

Show information for a route

This command displays the configuration of a route specified by index number.

Parameters

int $index

The index of the route as given by routing:list

Return Value

void

Exceptions

StopCommandException

void getPathCommand(string $package, string $controller = 'Standard', string $action = 'index', string $format = 'html') deprecated

deprecated since 7.0 @see resolveCommand(). Will probably be removed with 8.0

internal  
 

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

Parameters

string $package

Package key and subpackage, subpackage parts are separated with backslashes

string $controller

Controller name, default is 'Standard'

string $action

Action name, default is 'index'

string $format

Requested Format name default is 'html'

Return Value

void

Exceptions

StopCommandException

void resolveCommand(string $package, string $controller = null, string $action = null, string $format = null, string $subpackage = null, string $additionalArguments = null, string $parameters = null, string $baseUri = null, bool $forceAbsoluteUri = null)

Build an URI for the given parameters

This command takes package, controller and action and displays the resolved URI and which route matched (if any):

./flow routing:resolve Some.Package --controller SomeController --additional-arguments="{\"some-argument\": \"some-value\"}"

Parameters

string $package

Package key (according to "@package" route value)

string $controller

Controller name (according to "@controller" route value), default is 'Standard'

string $action

Action name (according to "@action" route value), default is 'index'

string $format

Requested Format name (according to "@format" route value), default is 'html'

string $subpackage

SubPackage name (according to "@subpackage" route value)

string $additionalArguments

Additional route values as JSON string. Make sure to specify this option as described in the description in order to prevent parsing issues

string $parameters

Route parameters as JSON string. Make sure to specify this option as described in the description in order to prevent parsing issues

string $baseUri

Base URI of the simulated request, default ist 'http://localhost'

bool $forceAbsoluteUri

Whether or not to force the creation of an absolute URI

Return Value

void

Exceptions

StopCommandException

void routePathCommand(string $path, string $method = 'GET') deprecated

deprecated since 7.0 @see matchCommand(). Will probably be removed with 8.0

internal  
 

Route the given route path

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

Parameters

string $path

The route path to resolve

string $method

The request method (GET, POST, PUT, DELETE, ...) to simulate

Return Value

void

Exceptions

InvalidRoutePartValueException

void matchCommand(string $uri, string $method = null, string $parameters = null)

Match the given URI to a corresponding route

This command takes an incoming URI and displays the matched Route and the mapped routing values (if any):

./flow routing:match "/de" --parameters="{\"requestUriHost\": \"localhost\"}"

Parameters

string $uri

The incoming route, absolute or relative

string $method

The HTTP method to simulate (default is 'GET')

string $parameters

Route parameters as JSON string. Make sure to specify this option as described in the description in order to prevent parsing issues

Return Value

void

Exceptions

InvalidRoutePartValueException