PHP Class EllipseSynergie\ApiResponse\AbstractResponse

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Author: Maxime Beaudoin ([email protected])
Author: Phil Sturgeon ([email protected])
Inheritance: implements EllipseSynergie\ApiResponse\Contracts\Response
Datei anzeigen Open project: ellipsesynergie/api-response Class Usage Examples

Protected Properties

Property Type Description
$manager League\Fractal\Manager Fractal manager
$statusCode integer HTTP Status code

Public Methods

Method Description
__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

Method Details

__construct() public method

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

errorForbidden() public method

Generates a response with a 403 HTTP header and a given message.
public errorForbidden ( string $message = 'Forbidden', array $headers = [] ) : mixed
$message string
$headers array
return mixed

errorGone() public method

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
return mixed

errorInternalError() public method

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
return mixed

errorMethodNotAllowed() public method

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
return mixed

errorNotFound() public method

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
return mixed

errorUnauthorized() public method

Generates a response with a 401 HTTP header and a given message.
public errorUnauthorized ( string $message = 'Unauthorized', array $headers = [] ) : mixed
$message string
$headers array
return mixed

errorUnprocessable() public method

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
return mixed

errorUnwillingToProcess() public method

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
return mixed

errorWrongArgs() public method

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
return mixed

getManager() public method

public getManager ( ) : League\Fractal\Manager
return League\Fractal\Manager

getStatusCode() public method

Getter for statusCode
public getStatusCode ( ) : integer
return integer

setStatusCode() public method

Setter for status code
public setStatusCode ( integer $statusCode ) : AbstractResponse
$statusCode integer
return AbstractResponse

withArray() abstract public method

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

withCollection() public method

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
return mixed

withError() public method

Response for errors
public withError ( string $message, string $errorCode, array $headers = [] ) : mixed
$message string
$errorCode string
$headers array
return mixed

withItem() public method

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
return mixed

Property Details

$manager protected_oe property

Fractal manager
protected Manager,League\Fractal $manager
return League\Fractal\Manager

$statusCode protected_oe property

HTTP Status code
protected int $statusCode
return integer