Documentation

ServiceRestTransport extends ServiceHttpTransport
in package

REST transport for all services.

Tags
author

Dodonov A.A.

Table of Contents

$paramsFetcher  : RequestParamsInterface|null
Request params fetcher
$router  : Router
Router
$serviceLogics  : array<string|int, ServiceBaseLogic>
Service's logic objects array
__construct()  : mixed
Constructor
addRoute()  : void
Method adds's route
addServiceLogic()  : void
Method adds service logic
callLogic()  : mixed
Method runs logic functions
callPublicLogic()  : mixed
Method runs logic functions
errorResponse()  : array<string|int, mixed>
Error response compilator
fetchActions()  : void
Method fetches actions for routes
getParam()  : string
Method returns parameter
getParamsFetcher()  : RequestParamsInterface
Method constructs request data fetcher
getRouter()  : Router
Method returns router
getServiceLogics()  : array<string|int, ServiceBaseLogic>
Method returns list of user logics
handleException()  : void
Method processes exception
loadRoute()  : void
Method loads single route
loadRoutes()  : void
Method loads routes
loadRoutesFromConfig()  : void
Method loads routes from config file
outputException()  : void
Method outputs exception data
routeExists()  : bool
Method returns true if the router exists
run()  : void
Method runs router
setServiceLogic()  : void
Method sets service logic
setServiceLogics()  : void
Method sets service logic
callRoute()  : void
Method calls route in transport specific way
createFetcher()  : RequestParamsInterface
Method creates parameters fetcher
formatCallStack()  : array<string|int, mixed>
Formatting call stack
getNecessaryLogic()  : ServiceBaseLogic
Method searches necessary logic object
header()  : void
Method outputs HTTP header
logicCallPrepend()  : void
This method is called before logic calls

Properties

Methods

__construct()

Constructor

public __construct() : mixed
Return values
mixed

addRoute()

Method adds's route

public addRoute(string $route, string $callback, mixed $requestMethod[, string $callType = 'callLogic' ]) : void
Parameters
$route : string

route

$callback : string

logic method to be called

$requestMethod : mixed

HTTP request method

$callType : string = 'callLogic'

type of the call

Tags
see
TransportInterface::addRoute()
Return values
void

callLogic()

Method runs logic functions

public callLogic(ServiceBaseLogic $serviceLogic, string $method[, array<string|int, mixed> $params = [] ]) : mixed
Parameters
$serviceLogic : ServiceBaseLogic

object with all service logic

$method : string

logic's method to be executed

$params : array<string|int, mixed> = []

logic's parameters

Return values
mixed

Result of the called method

callPublicLogic()

Method runs logic functions

public callPublicLogic(ServiceBaseLogic $serviceLogic, string $method[, array<string|int, mixed> $params = [] ]) : mixed
Parameters
$serviceLogic : ServiceBaseLogic

object with all service logic

$method : string

logic's method to be executed

$params : array<string|int, mixed> = []

logic's parameters

Return values
mixed

result of the called method

errorResponse()

Error response compilator

public errorResponse(mixed $e) : array<string|int, mixed>
Parameters
$e : mixed

exception object

Return values
array<string|int, mixed>

error data

getParam()

Method returns parameter

public getParam(string $param[, mixed $default = false ]) : string
Parameters
$param : string

Parameter name

$default : mixed = false

Default value

Return values
string

Parameter value

loadRoute()

Method loads single route

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

route description

Return values
void

loadRoutes()

Method loads routes

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

route descriptions

Tags
see
TransportInterface::loadRoutes()
Return values
void

loadRoutesFromConfig()

Method loads routes from config file

public loadRoutesFromConfig([string $path = './Conf/Routes.php' ]) : void
Parameters
$path : string = './Conf/Routes.php'

path to the routes description

Tags
see
TransportInterface::loadRoutesFromConfig()
Return values
void

outputException()

Method outputs exception data

public outputException(array<string|int, mixed> $e) : void
Parameters
$e : array<string|int, mixed>

exception data

Return values
void

routeExists()

Method returns true if the router exists

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

checking route

Return values
bool

true if the router exists, false otherwise

setServiceLogics()

Method sets service logic

public setServiceLogics(array<string|int, ServiceBaseLogic$serviceLogics) : void
Parameters
$serviceLogics : array<string|int, ServiceBaseLogic>

list of logic objects

Return values
void

callRoute()

Method calls route in transport specific way

protected callRoute() : void
Return values
void

formatCallStack()

Formatting call stack

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

Exception object

Return values
array<string|int, mixed>

Call stack

getNecessaryLogic()

Method searches necessary logic object

protected getNecessaryLogic(string $method) : ServiceBaseLogic
Parameters
$method : string

necessary method

Return values
ServiceBaseLogic

logic object

header()

Method outputs HTTP header

protected header(string $header, string $value) : void
Parameters
$header : string

header name

$value : string

header value

Tags
codeCoverageIgnore
Return values
void

Search results