Documentation

CommonApplication extends Application
in package

Common application with any available template

To load routes from the config call $this->load_routes_from_config('./Conf/routes.json');

The format of the *.json config must be like this:

[ { "route" : "/route1" , "callback" : "callback1" , "method" : "POST" } , { "route" : "/route2" , "callback" : "callback2" , "method" : ["GET" , "POST"] } ]

Table of Contents

$requestParams  : HttpRequestParams|null
Params fetcher
$router  : Router
Router object
$template  : HtmlTemplate|null
Application's template
__call()  : mixed
Allowing to call methods added on the fly
__construct()  : mixed
Constructor
buildRoute()  : array<string|int, mixed>
Method builds route data
crossRender()  : array<string|int, mixed>
Method renders common parts of all pages.
getRequestParamsFetcher()  : RequestParamsInterface
Method returns $this->requestParams and creates this object if necessery
getRouter()  : Router
Method returns router
getTemplate()  : HtmlTemplate
Getting template
handleException()  : void
Method processes exception.
handleRestException()  : void
Method processes exception.
loadActionsFromDirectories()  : void
Method loads actions from directories
loadActionsFromDirectory()  : void
Method loads actions from path
loadRoute()  : void
Method loads single route
loadRoutes()  : void
Method loads routes
loadRoutesFromConfig()  : void
Method loads routes from config file in *.php or *.json format
loadRoutesFromConfigs()  : void
Method loads list of configs
loadRoutesFromDirectory()  : void
Method loads routes from the directory
noRouteFoundErrorHandler()  : void
Method handles 404 errors
redirectTo()  : void
Method redirects user to another page
result()  : void
Method compiles result record
routeExists()  : bool
Method validates that route exists
run()  : void
Running application.
setTemplate()  : void
Setting template
baseFormatter()  : object
Method formats exception object
callRoute()  : mixed
Method calls route and returns it's content
formatBody()  : string|array<string|int, mixed>
Method formats body
formatCallStack()  : array<string|int, mixed>
Formatting call stack
formatRawBody()  : mixed
Method formats raw body
jsonFormatter()  : object
Method formats REST exception object
setGetVar()  : void
Method sets GET parameter as template var
loadActionsFromConfig()  : void
Method loads all actions from ./Actions directory

Properties

Methods

__call()

Allowing to call methods added on the fly

public __call(string $method, array<string|int, mixed> $args) : mixed
Parameters
$method : string

Method to be called

$args : array<string|int, mixed>

Arguments

Return values
mixed

Result of the call

buildRoute()

Method builds route data

public static buildRoute(string $route, string $method, object $handler, string $function) : array<string|int, mixed>
Parameters
$route : string

route

$method : string

HTTP method

$handler : object

object wich handles request

$function : string

controller's function name

Return values
array<string|int, mixed>

built route data

crossRender()

Method renders common parts of all pages.

public crossRender() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of common parts.

handleException()

Method processes exception.

public handleException(Exception $e) : void
Parameters
$e : Exception

Exception object.

Return values
void

handleRestException()

Method processes exception.

public handleRestException(Exception $e) : void
Parameters
$e : Exception

RestException object.

Return values
void

loadActionsFromDirectories()

Method loads actions from directories

public loadActionsFromDirectories(array<string|int, mixed> $paths) : void
Parameters
$paths : array<string|int, mixed>

to directories with actions

Return values
void

loadActionsFromDirectory()

Method loads actions from path

public loadActionsFromDirectory(string $path) : void
Parameters
$path : string
Return values
void

loadRoute()

Method loads single route

public loadRoute(array<string|int, mixed> $route) : void
Parameters
$route : array<string|int, mixed>

Route settings

Return values
void

loadRoutes()

Method loads routes

public loadRoutes(array<string|int, mixed> $routes) : void
Parameters
$routes : array<string|int, mixed>

List of routes

Return values
void

loadRoutesFromConfig()

Method loads routes from config file in *.php or *.json format

public loadRoutesFromConfig(string $configPath) : void
Parameters
$configPath : string

Path of the config for routes

Return values
void

loadRoutesFromConfigs()

Method loads list of configs

public loadRoutesFromConfigs(array<string|int, mixed> $configPaths) : void
Parameters
$configPaths : array<string|int, mixed>

paths to config files

Return values
void

loadRoutesFromDirectory()

Method loads routes from the directory

public loadRoutesFromDirectory(string $directory) : void
Parameters
$directory : string

path to the directory. Scanninng is recursive.

Return values
void

noRouteFoundErrorHandler()

Method handles 404 errors

public noRouteFoundErrorHandler() : void
Tags
codeCoverageIgnore
Return values
void

redirectTo()

Method redirects user to another page

public redirectTo(string $url) : void
Parameters
$url : string

New page

Return values
void

result()

Method compiles result record

public result([mixed $presenter = null ]) : void
Parameters
$presenter : mixed = null

main area presenter

Return values
void

result record

routeExists()

Method validates that route exists

public routeExists(string $route) : bool
Parameters
$route : string

route

Return values
bool

true if the route exists

baseFormatter()

Method formats exception object

protected baseFormatter(Exception $e) : object
Parameters
$e : Exception

Exception

Return values
object

Formatted exception object

callRoute()

Method calls route and returns it's content

protected callRoute() : mixed
Return values
mixed

route processing result

formatBody()

Method formats body

protected formatBody(string $body) : string|array<string|int, mixed>
Parameters
$body : string

body to be formatted

Return values
string|array<string|int, mixed>

formatted bodt

formatCallStack()

Formatting call stack

protected formatCallStack(mixed $e) : array<string|int, mixed>
Parameters
$e : mixed

Exception object

Return values
array<string|int, mixed>

formatRawBody()

Method formats raw body

protected formatRawBody(string $body) : mixed
Parameters
$body : string

raw body

Return values
mixed

formatted body or raw if it was not parsed

jsonFormatter()

Method formats REST exception object

protected jsonFormatter(Exception $e) : object
Parameters
$e : Exception

Exception

Return values
object

Formatted exception object

setGetVar()

Method sets GET parameter as template var

protected setGetVar(string $fieldName) : void
Parameters
$fieldName : string

name of the GET parameter

Return values
void

loadActionsFromConfig()

Method loads all actions from ./Actions directory

private loadActionsFromConfig() : void
Return values
void

Search results

    Яндекс.Метрика