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
파일 보기 프로젝트 열기: ellipsesynergie/api-response 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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