BaseController
Controller trait
Table of Contents
Properties
- $container : Container|null
- Container
- $dataErrorCallback : Closure|null
- Data error callback
- $dataValidCallback : Closure|null
- Data validatin callback
- $extensionName : string|null
- Extension name
- $pageName : string|null
- Page name
- $params : array<string|int, mixed>
- Controller params
- $response : ResponseInterface|null
- Response
Methods
- get() : mixed
- Get item from container
- getContainer() : Container
- Get container
- getDataValidCallback() : Closure|null
- Get data validation callback
- getExtensionName() : string|null
- Get extension name
- getPageName() : string|null
- Get page name
- getPageUrl() : string
- Get page url
- getParam() : mixed|null
- Get param
- getParams() : array<string|int, mixed>
- Get params
- getQueryParam() : mixed
- Get query param
- getRequestParams() : array<string|int, mixed>
- Get request params
- getUrl() : string
- Get url
- getValidationErrorCallback() : Closure|null
- Get validation error callback
- has() : bool
- Return true if container item esist
- hasService() : bool
- Return true service exists
- logError() : bool
- Log error
- logInfo() : bool
- Log message
- noCacheHeaders() : ResponseInterface
- Set no cache in Cache-Control
- onDataValid() : void
- Set callback for validation done
- onValidationError() : void
- Set callback for validation errors
- resolveRequestParams() : array<string|int, mixed>
- Resolve params
- setExtensionName() : void
- Set extension name
- setHttpResponse() : void
- Set http response instance
- withRedirect() : ResponseInterface
- Set redirect headers
- withService() : mixed
- Run closure with serice
- resolveRouteParams() : bool
- Resolve route params
Properties
$container
Container
protected
Container|null
$container
= null
$dataErrorCallback
Data error callback
protected
Closure|null
$dataErrorCallback
= null
$dataValidCallback
Data validatin callback
protected
Closure|null
$dataValidCallback
= null
$extensionName
Extension name
protected
string|null
$extensionName
= null
$pageName
Page name
protected
string|null
$pageName
= null
$params
Controller params
protected
array<string|int, mixed>
$params
= []
$response
Response
protected
ResponseInterface|null
$response
= null
Methods
get()
Get item from container
public
get(string $id) : mixed
Parameters
- $id : string
getContainer()
Get container
public
getContainer() : Container
Return values
ContainergetDataValidCallback()
Get data validation callback
public
getDataValidCallback() : Closure|null
Return values
Closure|nullgetExtensionName()
Get extension name
public
getExtensionName() : string|null
Return values
string|nullgetPageName()
Get page name
public
getPageName() : string|null
Return values
string|nullgetPageUrl()
Get page url
public
getPageUrl([string $path = '' ][, bool $relative = false ][, string|null $language = null ]) : string
Parameters
- $path : string = ''
- $relative : bool = false
- $language : string|null = null
Return values
stringgetParam()
Get param
public
getParam(string $key[, mixed|null $default = null ]) : mixed|null
Parameters
- $key : string
- $default : mixed|null = null
Return values
mixed|nullgetParams()
Get params
public
getParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getQueryParam()
Get query param
public
getQueryParam(ServerRequestInterface $request, string $name[, mixed $default = null ]) : mixed
Parameters
- $request : ServerRequestInterface
- $name : string
- $default : mixed = null
getRequestParams()
Get request params
public
getRequestParams(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Return values
array<string|int, mixed>getUrl()
Get url
public
getUrl(ServerRequestInterface $request[, bool $relative = false ]) : string
Parameters
- $request : ServerRequestInterface
- $relative : bool = false
Return values
stringgetValidationErrorCallback()
Get validation error callback
public
getValidationErrorCallback() : Closure|null
Return values
Closure|nullhas()
Return true if container item esist
public
has(string $id) : bool
Parameters
- $id : string
Return values
boolhasService()
Return true service exists
public
hasService(string $id) : bool
Parameters
- $id : string
Return values
boollogError()
Log error
public
logError(string $message[, array<string|int, mixed> $context = [] ]) : bool
Parameters
- $message : string
- $context : array<string|int, mixed> = []
Return values
boollogInfo()
Log message
public
logInfo(string $message[, array<string|int, mixed> $context = [] ]) : bool
Parameters
- $message : string
- $context : array<string|int, mixed> = []
Return values
boolnoCacheHeaders()
Set no cache in Cache-Control
public
noCacheHeaders(mixed $response) : ResponseInterface
Parameters
- $response : mixed
Return values
ResponseInterfaceonDataValid()
Set callback for validation done
public
onDataValid(Closure $callback) : void
Parameters
- $callback : Closure
onValidationError()
Set callback for validation errors
public
onValidationError(Closure $callback) : void
Parameters
- $callback : Closure
resolveRequestParams()
Resolve params
public
resolveRequestParams(Request $request, array<string|int, mixed> $paramsKeys) : array<string|int, mixed>
Parameters
- $request : Request
- $paramsKeys : array<string|int, mixed>
Return values
array<string|int, mixed>setExtensionName()
Set extension name
public
setExtensionName(string|null $name) : void
Parameters
- $name : string|null
setHttpResponse()
Set http response instance
public
setHttpResponse(ResponseInterface $response) : void
Parameters
- $response : ResponseInterface
withRedirect()
Set redirect headers
public
withRedirect(ResponseInterface $response, string $url) : ResponseInterface
Parameters
- $response : ResponseInterface
- $url : string
Return values
ResponseInterfacewithService()
Run closure with serice
public
withService(string $name, Closure $callback) : mixed
Parameters
- $name : string
- $callback : Closure
resolveRouteParams()
Resolve route params
protected
resolveRouteParams(Request $request) : bool
Parameters
- $request : Request