PHP Класс Dispatcher

Автор: liu21st ([email protected])
Наследование: extends Base
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
asJSON ( array $data = [] ) : SS_HTTPResponse Respond to an AJAX request.
asJSONFormFieldErrors ( integer $code, array $fieldErrors ) : SS_HTTPResponse Return field-specific errors as AJAX response.
asJSONValidatorErrors ( integer $code, array $validatorErrors ) : SS_HTTPResponse Return the validator errors as AJAX response.
getModel ( string $name ) : array Generate the data structure used by the frontend component.
getReactComponent ( string $name ) : string Renders the initial HTML needed to bootstrap the react component.

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

Метод Описание
checkSecurityToken ( )
getAPIResponse ( array $output, integer $statusCode ) : SS_HTTPResponse Return an XHR response object without any CSRF token information
getFormData ( ) : array Decode the data submitted by the Form.jsx control.
getSecurityToken ( ) : SecurityToken We want to separate the dispatchers security token from the static HTML security token since it's possible that they get out of sync with eachother.
stripNonPrintables ( $val ) : string | array Remove control characters from the input.
trimWhitespace ( $val ) : string | array

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

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

Automatically updates the security token and proxy pending redirects.
Устаревший: the use of getAPIResponse() is encouraged
public asJSON ( array $data = [] ) : SS_HTTPResponse
$data array Data to be passed to the frontend.
Результат SS_HTTPResponse

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

Return field-specific errors as AJAX response.
public asJSONFormFieldErrors ( integer $code, array $fieldErrors ) : SS_HTTPResponse
$code integer HTTP status code.
$fieldErrors array FieldName => message structure.
Результат SS_HTTPResponse

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

Return the validator errors as AJAX response.
public asJSONValidatorErrors ( integer $code, array $validatorErrors ) : SS_HTTPResponse
$code integer HTTP status code.
$validatorErrors array Result of calling Validator::validate, e.g. [{"fieldName":"Name","message":"Message.","messageType":"bad"}]
Результат SS_HTTPResponse

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

См. также: getSecurityToken()
protected checkSecurityToken ( )

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

Return an XHR response object without any CSRF token information
protected getAPIResponse ( array $output, integer $statusCode ) : SS_HTTPResponse
$output array
$statusCode integer
Результат SS_HTTPResponse

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

Decode the data submitted by the Form.jsx control.
protected getFormData ( ) : array
Результат array

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

Generate the data structure used by the frontend component.
abstract public getModel ( string $name ) : array
$name string of the component
Результат array

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

Usage: $getReactComponent(YourComponent);
public getReactComponent ( string $name ) : string
$name string Used to name the DOM elements and obtain the initial model.
Результат string A snippet good for adding to a SS template.

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

We do this by giving the token a separate name. Don't manually reset() this token, that will cause issues when people have several tabs open. The token will be recreated when the user session times out.
protected getSecurityToken ( ) : SecurityToken
Результат SecurityToken

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

Remove control characters from the input.
protected stripNonPrintables ( $val ) : string | array
Результат string | array

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

protected trimWhitespace ( $val ) : string | array
Результат string | array