PHP Класс Scalr\Api\Rest\Application

С версии: 5.4.0 (09.02.2015)
Автор: Vitaliy Demidov ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$startTime float API Application start time

Защищенные свойства (Protected)

Свойство Тип Описание
$pathPreprocessor callable Preprocess request method and path

Открытые методы

Метод Описание
__construct ( array $settings = [] ) Constructor
__get ( $name )
__isset ( $name )
addRoute ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route Adds a route to routing table
call ( ) Application wide handler
delete ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route Adds delete route
error ( Callable | Exception $e = null ) Error handler
get ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route Adds get route
getContainer ( ) : Container Gets API Container
getDefaultSettings ( )
getRouteUrl ( string $route, array $params = [] ) : string Gets url for the specified route
group ( ) Route Groups
halt ( number $status, string $message = '' ) Stops application immediately
handleApiVersion ( Scalr\Api\Rest\Routing\Route $route ) ApiVersion middleware handler
handleErrors ( integer $errno, string $errstr, string $errfile, integer $errline ) : boolean Error handler
notFound ( ) Not found handler
options ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route Adds options route
patch ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route Adds patch route
post ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route Adds post route
put ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route Adds put route
redirect ( string $url, number $status = 302 ) Redirects to the specified url
redirectTo ( string $route, array $params = [], number $status = 302 ) Redirects to the specified named route
run ( ) Runs application
stop ( ) Stops application

Защищенные методы

Метод Описание
callErrorHandler ( Exception $e = null ) : string Calls error handler
defaultError ( ErrorException $e = null ) : string Gets default error content
getDefaultTemplate ( string $title, string $body ) : string Parses default template and returns its content

Описание методов

__construct() публичный Метод

Constructor
public __construct ( array $settings = [] )
$settings array optional Application settings

__get() публичный Метод

public __get ( $name )

__isset() публичный Метод

public __isset ( $name )

addRoute() публичный Метод

Adds a route to routing table
public addRoute ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route
$path string The path pattern of the route
$options array | callable The options
$requirements array optional The requirements
Результат Scalr\Api\Rest\Routing\Route Returns route instance

call() публичный Метод

Application wide handler
public call ( )

callErrorHandler() защищенный Метод

Calls error handler
protected callErrorHandler ( Exception $e = null ) : string
$e Exception optional An exception
Результат string

defaultError() защищенный Метод

Gets default error content
protected defaultError ( ErrorException $e = null ) : string
$e ErrorException optional An Exception
Результат string

delete() публичный Метод

Adds delete route
public delete ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route
$path string The path pattern of the route
$options array | callable The options
$requirements array optional The requirements
Результат Scalr\Api\Rest\Routing\Route Returns route instance

error() публичный Метод

It registers error handler or invokes registered error handler with an exception
public error ( Callable | Exception $e = null )
$e Callable | Exception optional Either the callable handler or exception

get() публичный Метод

Adds get route
public get ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route
$path string The path pattern of the route
$options array | callable The options
$requirements array optional The requirements
Результат Scalr\Api\Rest\Routing\Route Returns route instance

getContainer() публичный Метод

Gets API Container
public getContainer ( ) : Container
Результат Scalr\DependencyInjection\Container Returns DI Container instance

getDefaultSettings() публичный статический Метод

public static getDefaultSettings ( )

getDefaultTemplate() защищенный Метод

Parses default template and returns its content
protected getDefaultTemplate ( string $title, string $body ) : string
$title string A title
$body string A body
Результат string Returns parsed template

getRouteUrl() публичный Метод

Gets url for the specified route
public getRouteUrl ( string $route, array $params = [] ) : string
$route string The name of the route
$params array optional The parameters
Результат string Returns the URL for the specified Route

group() публичный Метод

Route Groups
public group ( )

halt() публичный Метод

Stops application immediately
public halt ( number $status, string $message = '' )
$status number HTTP response status code
$message string optional The response message

handleApiVersion() публичный Метод

It extracts :apiversion group parameter from the route and sets application setting
public handleApiVersion ( Scalr\Api\Rest\Routing\Route $route )
$route Scalr\Api\Rest\Routing\Route A route

handleErrors() публичный статический Метод

Error handler
public static handleErrors ( integer $errno, string $errstr, string $errfile, integer $errline ) : boolean
$errno integer
$errstr string
$errfile string
$errline integer
Результат boolean

notFound() публичный Метод

Not found handler
public notFound ( )

options() публичный Метод

Adds options route
public options ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route
$path string The path pattern of the route
$options array | callable The options
$requirements array optional The requirements
Результат Scalr\Api\Rest\Routing\Route Returns route instance

patch() публичный Метод

Adds patch route
public patch ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route
$path string The path pattern of the route
$options array | callable The options
$requirements array optional The requirements
Результат Scalr\Api\Rest\Routing\Route Returns route instance

post() публичный Метод

Adds post route
public post ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route
$path string The path pattern of the route
$options array | callable The options
$requirements array optional The requirements
Результат Scalr\Api\Rest\Routing\Route Returns route instance

put() публичный Метод

Adds put route
public put ( string $path, array | callable $options, array $requirements = [] ) : Scalr\Api\Rest\Routing\Route
$path string The path pattern of the route
$options array | callable The options
$requirements array optional The requirements
Результат Scalr\Api\Rest\Routing\Route Returns route instance

redirect() публичный Метод

Redirects to the specified url
public redirect ( string $url, number $status = 302 )
$url string The URL
$status number optional The HTTP response status code

redirectTo() публичный Метод

Redirects to the specified named route
public redirectTo ( string $route, array $params = [], number $status = 302 )
$route string The name of the Route
$params array optional The list of the parameters
$status number optional The HTTP response status code.

run() публичный Метод

Runs application
public run ( )

stop() публичный Метод

Stops application
public stop ( )

Описание свойств

$pathPreprocessor защищенное свойство

Preprocess request method and path
protected callable $pathPreprocessor
Результат callable

$startTime публичное свойство

API Application start time
public float $startTime
Результат float