PHP Класс EllipseSynergie\ApiResponse\AbstractResponse

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Автор: Maxime Beaudoin ([email protected])
Автор: Phil Sturgeon ([email protected])
Наследование: implements EllipseSynergie\ApiResponse\Contracts\Response
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$manager League\Fractal\Manager Fractal manager
$statusCode integer HTTP Status code

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

Метод Описание
__construct ( League\Fractal\Manager $manager )
errorForbidden ( string $message = 'Forbidden', array $headers = [] ) : mixed Generates a response with a 403 HTTP header and a given message.
errorGone ( string $message = 'Resource No Longer Available', array $headers = [] ) : mixed Generates a response with a 410 HTTP header and a given message.
errorInternalError ( string $message = 'Internal Error', array $headers = [] ) : mixed Generates a response with a 500 HTTP header and a given message.
errorMethodNotAllowed ( string $message = 'Method Not Allowed', array $headers = [] ) : mixed Generates a response with a 405 HTTP header and a given message.
errorNotFound ( string $message = 'Resource Not Found', array $headers = [] ) : mixed Generates a response with a 404 HTTP header and a given message.
errorUnauthorized ( string $message = 'Unauthorized', array $headers = [] ) : mixed Generates a response with a 401 HTTP header and a given message.
errorUnprocessable ( string $message = 'Unprocessable Entity', array $headers = [] ) : mixed Generates a Response with a 422 HTTP header and a given message.
errorUnwillingToProcess ( string $message = 'Server is unwilling to process the request', array $headers = [] ) : mixed Generates a Response with a 431 HTTP header and a given message.
errorWrongArgs ( string $message = 'Wrong Arguments', array $headers = [] ) : mixed Generates a response with a 400 HTTP header and a given message.
getManager ( ) : League\Fractal\Manager
getStatusCode ( ) : integer Getter for statusCode
setStatusCode ( integer $statusCode ) : AbstractResponse Setter for status code
withArray ( array $array, array $headers = [] ) Implement this !!! This method return the final response output
withCollection ( $data, callable | League\Fractal\TransformerAbstract $transformer, string $resourceKey = null, League\Fractal\Pagination\Cursor $cursor = null, array $meta = [], array $headers = [] ) : mixed Response for collection of items
withError ( string $message, string $errorCode, array $headers = [] ) : mixed Response for errors
withItem ( $data, callable | League\Fractal\TransformerAbstract $transformer, string $resourceKey = null, array $meta = [], array $headers = [] ) : mixed Response for one item

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

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

public __construct ( League\Fractal\Manager $manager )
$manager League\Fractal\Manager

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

Generates a response with a 403 HTTP header and a given message.
public errorForbidden ( string $message = 'Forbidden', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a response with a 410 HTTP header and a given message.
public errorGone ( string $message = 'Resource No Longer Available', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a response with a 500 HTTP header and a given message.
public errorInternalError ( string $message = 'Internal Error', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a response with a 405 HTTP header and a given message.
public errorMethodNotAllowed ( string $message = 'Method Not Allowed', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a response with a 404 HTTP header and a given message.
public errorNotFound ( string $message = 'Resource Not Found', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a response with a 401 HTTP header and a given message.
public errorUnauthorized ( string $message = 'Unauthorized', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a Response with a 422 HTTP header and a given message.
public errorUnprocessable ( string $message = 'Unprocessable Entity', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a Response with a 431 HTTP header and a given message.
public errorUnwillingToProcess ( string $message = 'Server is unwilling to process the request', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

Generates a response with a 400 HTTP header and a given message.
public errorWrongArgs ( string $message = 'Wrong Arguments', array $headers = [] ) : mixed
$message string
$headers array
Результат mixed

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

public getManager ( ) : League\Fractal\Manager
Результат League\Fractal\Manager

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

Getter for statusCode
public getStatusCode ( ) : integer
Результат integer

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

Setter for status code
public setStatusCode ( integer $statusCode ) : AbstractResponse
$statusCode integer
Результат AbstractResponse

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

Implement this !!! This method return the final response output
abstract public withArray ( array $array, array $headers = [] )
$array array
$headers array

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

Response for collection of items
public withCollection ( $data, callable | League\Fractal\TransformerAbstract $transformer, string $resourceKey = null, League\Fractal\Pagination\Cursor $cursor = null, array $meta = [], array $headers = [] ) : mixed
$data
$transformer callable | League\Fractal\TransformerAbstract
$resourceKey string
$cursor League\Fractal\Pagination\Cursor
$meta array
$headers array
Результат mixed

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

Response for errors
public withError ( string $message, string $errorCode, array $headers = [] ) : mixed
$message string
$errorCode string
$headers array
Результат mixed

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

Response for one item
public withItem ( $data, callable | League\Fractal\TransformerAbstract $transformer, string $resourceKey = null, array $meta = [], array $headers = [] ) : mixed
$data
$transformer callable | League\Fractal\TransformerAbstract
$resourceKey string
$meta array
$headers array
Результат mixed

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

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

Fractal manager
protected Manager,League\Fractal $manager
Результат League\Fractal\Manager

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

HTTP Status code
protected int $statusCode
Результат integer