PHP Класс flight\Engine

It is responsible for loading an HTTP request, running the assigned services, and generating an HTTP response.
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$dispatcher object Event dispatcher.
$loader object Class loader.
$vars array Stored variables.

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

Метод Описание
__call ( string $name, array $params ) : mixed Handles calls to class methods.
__construct ( ) Constructor.
_error ( object $e ) Sends an HTTP 500 response for any errors.
_etag ( string $id, string $type = 'strong' ) Handles ETag HTTP caching.
_halt ( integer $code = 200, string $message = '' ) Stops processing and returns a given response.
_json ( mixed $data, integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option ) Sends a JSON response.
_jsonp ( mixed $data, string $param = 'jsonp', integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option ) Sends a JSONP response.
_lastModified ( integer $time ) Handles last modified HTTP caching.
_notFound ( ) Sends an HTTP 404 response when a URL is not found.
_redirect ( string $url, integer $code = 303 ) Redirects the current request to another URL.
_render ( string $file, array $data = null, string $key = null ) Renders a template.
_route ( string $pattern, callback $callback, boolean $pass_route = false ) Routes a URL to a callback function.
_start ( ) Starts the framework.
_stop ( integer $code = 200 ) Stops the framework and outputs the current response.
after ( string $name, callback $callback ) Adds a post-filter to a method.
before ( string $name, callback $callback ) Adds a pre-filter to a method.
clear ( string $key = null ) Unsets a variable. If no key is passed in, clear all variables.
get ( string $key = null ) : mixed Gets a variable.
handleError ( integer $errno, integer $errstr, integer $errfile, integer $errline ) Custom error handler. Converts errors into exceptions.
handleErrors ( boolean $enabled ) Enables/disables custom error handling.
handleException ( object $e ) Custom exception handler. Logs exceptions.
has ( string $key ) : boolean Checks if a variable has been set.
init ( ) Initializes the framework.
map ( string $name, callback $callback ) Maps a callback to a framework method.
path ( string $dir ) Adds a path for class autoloading.
register ( string $name, string $class, array $params = [], callback $callback = null ) Registers a class to a framework method.
set ( mixed $key, string $value = null ) Sets a variable.

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

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

Handles calls to class methods.
public __call ( string $name, array $params ) : mixed
$name string Method name
$params array Method parameters
Результат mixed Callback results

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

Constructor.
public __construct ( )

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

Sends an HTTP 500 response for any errors.
public _error ( object $e )
$e object Thrown exception

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

Handles ETag HTTP caching.
public _etag ( string $id, string $type = 'strong' )
$id string ETag identifier
$type string ETag type

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

Stops processing and returns a given response.
public _halt ( integer $code = 200, string $message = '' )
$code integer HTTP status code
$message string Response message

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

Sends a JSON response.
public _json ( mixed $data, integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option )
$data mixed JSON data
$code integer HTTP status code
$encode boolean Whether to perform JSON encoding
$charset string Charset
$option integer Bitmask Json constant such as JSON_HEX_QUOT

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

Sends a JSONP response.
public _jsonp ( mixed $data, string $param = 'jsonp', integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option )
$data mixed JSON data
$param string Query parameter that specifies the callback name.
$code integer HTTP status code
$encode boolean Whether to perform JSON encoding
$charset string Charset
$option integer Bitmask Json constant such as JSON_HEX_QUOT

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

Handles last modified HTTP caching.
public _lastModified ( integer $time )
$time integer Unix timestamp

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

Sends an HTTP 404 response when a URL is not found.
public _notFound ( )

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

Redirects the current request to another URL.
public _redirect ( string $url, integer $code = 303 )
$url string URL
$code integer HTTP status code

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

Renders a template.
public _render ( string $file, array $data = null, string $key = null )
$file string Template file
$data array Template data
$key string View variable name

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

Routes a URL to a callback function.
public _route ( string $pattern, callback $callback, boolean $pass_route = false )
$pattern string URL pattern to match
$callback callback Callback function
$pass_route boolean Pass the matching route object to the callback

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

Starts the framework.
public _start ( )

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

Stops the framework and outputs the current response.
public _stop ( integer $code = 200 )
$code integer HTTP status code

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

Adds a post-filter to a method.
public after ( string $name, callback $callback )
$name string Method name
$callback callback Callback function

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

Adds a pre-filter to a method.
public before ( string $name, callback $callback )
$name string Method name
$callback callback Callback function

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

Unsets a variable. If no key is passed in, clear all variables.
public clear ( string $key = null )
$key string Key

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

Gets a variable.
public get ( string $key = null ) : mixed
$key string Key
Результат mixed

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

Custom error handler. Converts errors into exceptions.
public handleError ( integer $errno, integer $errstr, integer $errfile, integer $errline )
$errno integer Error number
$errstr integer Error string
$errfile integer Error file name
$errline integer Error file line number

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

Enables/disables custom error handling.
public handleErrors ( boolean $enabled )
$enabled boolean True or false

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

Custom exception handler. Logs exceptions.
public handleException ( object $e )
$e object Thrown exception

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

Checks if a variable has been set.
public has ( string $key ) : boolean
$key string Key
Результат boolean Variable status

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

Initializes the framework.
public init ( )

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

Maps a callback to a framework method.
public map ( string $name, callback $callback )
$name string Method name
$callback callback Callback function

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

Adds a path for class autoloading.
public path ( string $dir )
$dir string Directory path

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

Registers a class to a framework method.
public register ( string $name, string $class, array $params = [], callback $callback = null )
$name string Method name
$class string Class name
$params array Class initialization parameters
$callback callback Function to call after object instantiation

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

Sets a variable.
public set ( mixed $key, string $value = null )
$key mixed Key
$value string Value

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

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

Event dispatcher.
protected object $dispatcher
Результат object

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

Class loader.
protected object $loader
Результат object

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

Stored variables.
protected array $vars
Результат array