CliRequest
extends InputRequest
in package
Table of Contents
Constants
- VERBOSITY_DEBUG = 256
- VERBOSITY_NORMAL = 32
- VERBOSITY_QUIET = 16
- VERBOSITY_VERBOSE = 64
- VERBOSITY_VERY_VERBOSE = 128
Properties
- $dryRun : bool
- $input : array<string|int, mixed>|string|null
- The input (like stdin)
- $mainRequest : static|null
- The current main request
- $parameters : array<string|int, mixed>
- The input parameters (inline parameters)
- $path : string
- The path
- $pathValues : array<string|int, mixed>
- The values in path
- $route : ControllerRoute|null
- The found route for this request A request could exist without any route (e.g. Route initialization failed)
- $verbosity : int
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Get this request as string
- cloneWithPath() : InputRequest
- Clone this request using another path (expecting a sub path)
- findFirstMatchingRoute() : array<string|int, mixed>
- Find a matching route according to the request
- generateFromEnvironment() : CliRequest
- Generate CliRequest from environment
- getAllData() : array<string|int, mixed>
- Get all input data
- getArgument() : string|null
- getArrayData() : mixed
- Get the data by key with array as default
- getController() : AbstractController
- Get running controller
- getData() : mixed
- Get a data by $key, assuming $default
- getDefaultController() : CliController
- getInput() : array<string|int, mixed>
- Get input
- getInputValue() : mixed
- Get the input by $key, assuming $default value
- getMainRequest() : InputRequest|null
- Get the main input request
- getOption() : mixed
- Get the option by $key, assuming $default value
- getParameter() : mixed
- Get the parameter by $key, assuming $default value
- getParameters() : array<string|int, mixed>
- Get all parameters
- getPath() : string
- Get the path
- getRoute() : ControllerRoute|null
- Get the route to this request
- getRouteClass() : string
- Get the name of the route class associated to a CliRequest
- getRouteName() : string
- Get the route name to this request
- getRoutes() : array<string|int, CliRoute>
- Get all available routes
- getUrl() : string
- Get the URL used for this request
- getVerbosity() : int
- handleCurrentRequest() : void
- Handle the current request as a CliRequest one This method ends the script
- hasArrayData() : bool
- Test if data $key is an array
- hasData() : bool
- Test if data contains the $key
- hasDataKey() : bool
- Test if path contains a value and return it as parameter
- hasInput() : bool
- Test if request has any input
- hasInputValue() : bool
- Test if input $key exists in this request
- hasParameter() : bool
- Test if parameter $key exists in this request
- isDebugVerbose() : bool
- isDryRun() : bool
- isVerbose() : bool
- isVeryVerbose() : bool
- matchPath() : string
- Test path is matching regex
- process() : OutputResponse
- Process the request by finding a route and processing it
- processRoute() : OutputResponse
- Process the given route
- redirect() : RedirectHttpResponse|null
- Redirect response to $route
- setDryRun() : void
- setRoute() : InputRequest
- Set the route to this request
- setVerbosity() : void
- parseArguments() : array<string|int, mixed>
- Parse console arguments to parameters with option
- setContent() : CliRequest
- Set the content (input & input type)
- setInput() : InputRequest
- Set the input
- setParameters() : InputRequest
- Set the parameters
- setPath() : InputRequest
- Set the path
Constants
VERBOSITY_DEBUG
public
mixed
VERBOSITY_DEBUG
= 256
VERBOSITY_NORMAL
public
mixed
VERBOSITY_NORMAL
= 32
VERBOSITY_QUIET
public
mixed
VERBOSITY_QUIET
= 16
VERBOSITY_VERBOSE
public
mixed
VERBOSITY_VERBOSE
= 64
VERBOSITY_VERY_VERBOSE
public
mixed
VERBOSITY_VERY_VERBOSE
= 128
Properties
$dryRun
protected
bool
$dryRun
= false
$input
The input (like stdin)
protected
array<string|int, mixed>|string|null
$input
$mainRequest
The current main request
protected
static static|null
$mainRequest
= null
$parameters
The input parameters (inline parameters)
protected
array<string|int, mixed>
$parameters
$path
The path
protected
string
$path
$pathValues
The values in path
protected
array<string|int, mixed>
$pathValues
$route
The found route for this request A request could exist without any route (e.g. Route initialization failed)
protected
ControllerRoute|null
$route
= null
$verbosity
protected
int
$verbosity
= self::VERBOSITY_NORMAL
Methods
__construct()
Constructor
public
__construct(mixed $path, mixed $parameters, mixed $input) : mixed
Parameters
- $path : mixed
- $parameters : mixed
- $input : mixed
__toString()
Get this request as string
public
__toString() : string
Return values
stringcloneWithPath()
Clone this request using another path (expecting a sub path)
public
cloneWithPath(string $path) : InputRequest
Parameters
- $path : string
Return values
InputRequestfindFirstMatchingRoute()
Find a matching route according to the request
public
findFirstMatchingRoute() : array<string|int, mixed>
Return values
array<string|int, mixed>generateFromEnvironment()
Generate CliRequest from environment
public
static generateFromEnvironment() : CliRequest
Return values
CliRequestgetAllData()
Get all input data
public
getAllData() : array<string|int, mixed>
Return values
array<string|int, mixed>getArgument()
public
getArgument(int $index) : string|null
Parameters
- $index : int
Return values
string|nullgetArrayData()
Get the data by key with array as default
public
getArrayData(string $key) : mixed
Parameters
- $key : string
getController()
Get running controller
public
getController() : AbstractController
Return values
AbstractControllergetData()
Get a data by $key, assuming $default
public
getData(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getDefaultController()
public
static getDefaultController() : CliController
Return values
CliControllergetInput()
Get input
public
getInput() : array<string|int, mixed>
Return values
array<string|int, mixed>getInputValue()
Get the input by $key, assuming $default value
public
getInputValue(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getMainRequest()
Get the main input request
public
static getMainRequest() : InputRequest|null
Return values
InputRequest|nullgetOption()
Get the option by $key, assuming $default value
public
getOption(string $key[, string|null $short = null ][, mixed|null $default = null ]) : mixed
Parameters
- $key : string
- $short : string|null = null
- $default : mixed|null = null
getParameter()
Get the parameter by $key, assuming $default value
public
getParameter(string $key[, mixed|null $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed|null = null
getParameters()
Get all parameters
public
getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>getPath()
Get the path
public
getPath() : string
Return values
stringgetRoute()
Get the route to this request
public
getRoute() : ControllerRoute|null
Return values
ControllerRoute|nullgetRouteClass()
Get the name of the route class associated to a CliRequest
public
static getRouteClass() : string
Return values
stringgetRouteName()
Get the route name to this request
public
getRouteName() : string
Return values
stringgetRoutes()
Get all available routes
public
getRoutes() : array<string|int, CliRoute>
Tags
Return values
array<string|int, CliRoute>getUrl()
Get the URL used for this request
public
getUrl() : string
Return values
stringgetVerbosity()
public
getVerbosity() : int
Return values
inthandleCurrentRequest()
Handle the current request as a CliRequest one This method ends the script
public
static handleCurrentRequest() : void
hasArrayData()
Test if data $key is an array
public
hasArrayData([string $key = null ]) : bool
Parameters
- $key : string = null
Return values
boolhasData()
Test if data contains the $key
public
hasData([string|null $key = null ]) : bool
Parameters
- $key : string|null = null
Return values
boolhasDataKey()
Test if path contains a value and return it as parameter
public
hasDataKey([string $path = null ][, string &$value = null ]) : bool
Parameters
- $path : string = null
-
The path to get the value
- $value : string = null
-
The value as output parameter
Return values
boolhasInput()
Test if request has any input
public
hasInput() : bool
Return values
boolhasInputValue()
Test if input $key exists in this request
public
hasInputValue(string $key) : bool
Parameters
- $key : string
Return values
boolhasParameter()
Test if parameter $key exists in this request
public
hasParameter(string $key) : bool
Parameters
- $key : string
Return values
boolisDebugVerbose()
public
isDebugVerbose() : bool
Return values
boolisDryRun()
public
isDryRun() : bool
Return values
boolisVerbose()
public
isVerbose() : bool
Return values
boolisVeryVerbose()
public
isVeryVerbose() : bool
Return values
boolmatchPath()
Test path is matching regex
public
matchPath(string $regex, array<string|int, mixed>|null &$matches) : string
Parameters
- $regex : string
- $matches : array<string|int, mixed>|null
Return values
stringprocess()
Process the request by finding a route and processing it
public
process() : OutputResponse
Tags
Return values
OutputResponseprocessRoute()
Process the given route
public
processRoute(ControllerRoute $route, array<string|int, mixed> $values) : OutputResponse
Parameters
- $route : ControllerRoute
- $values : array<string|int, mixed>
Tags
Return values
OutputResponseredirect()
Redirect response to $route
public
redirect(ControllerRoute $route) : RedirectHttpResponse|null
Parameters
- $route : ControllerRoute
Return values
RedirectHttpResponse|null —Should be overridden to be used
setDryRun()
public
setDryRun(bool $dryRun) : void
Parameters
- $dryRun : bool
setRoute()
Set the route to this request
public
setRoute(ControllerRoute $route, array<string|int, mixed> $values) : InputRequest
Parameters
- $route : ControllerRoute
- $values : array<string|int, mixed>
Return values
InputRequestsetVerbosity()
public
setVerbosity(int $verbosity) : void
Parameters
- $verbosity : int
parseArguments()
Parse console arguments to parameters with option
protected
static parseArguments(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
Return values
array<string|int, mixed>setContent()
Set the content (input & input type)
protected
setContent(string $content) : CliRequest
Parameters
- $content : string
Tags
Return values
CliRequestsetInput()
Set the input
protected
setInput(array<string|int, mixed>|string|null $input) : InputRequest
Parameters
- $input : array<string|int, mixed>|string|null
Return values
InputRequestsetParameters()
Set the parameters
protected
setParameters(array<string|int, mixed> $parameters) : InputRequest
Parameters
- $parameters : array<string|int, mixed>
Return values
InputRequestsetPath()
Set the path
protected
setPath(string $path) : InputRequest
Parameters
- $path : string