PHP 클래스 Flugg\Responder\Http\SuccessResponseBuilder

저자: Alexander Tømmerås ([email protected])
상속: extends ResponseBuilder
파일 보기 프로젝트 열기: flugger/laravel-responder 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$manager League\Fractal\Manager The manager responsible for transforming and serializing data.
$meta array The meta data appended to the serialized data.
$relations array The included relations.
$resource League\Fractal\Resource\ResourceInterface The Fractal resource instance containing the data and transformer.
$resourceFactory Flugg\Responder\ResourceFactory The resource factory used to generate resource instances.
$statusCode integer The HTTP status code for the response.

공개 메소드들

메소드 설명
__construct ( Illuminate\Contracts\Routing\ResponseFactory | ResponseFactory $responseFactory, ResourceFactory $resourceFactory, League\Fractal\Manager $manager ) SuccessResponseBuilder constructor.
addMeta ( array $data ) : SuccessResponseBuilder Add data to the meta data appended to the response data.
getManager ( ) : League\Fractal\Manager Get the Fractal manager responsible for transforming and serializing the data.
getResource ( ) : League\Fractal\Resource\ResourceInterface Get the Fractal resource instance.
include ( array | string $relations ) : SuccessResponseBuilder Set the serializer used to serialize the resource data.
serializer ( League\Fractal\Serializer\SerializerAbstract | string $serializer ) : SuccessResponseBuilder Set the serializer used to serialize the resource data.
setStatus ( integer $statusCode ) : ResponseBuilder Set the HTTP status code for the response.
toArray ( ) : array Convert the response to an array.
transform ( mixed | null $data = null, callable | string | null $transformer = null, string $resourceKey = null ) : SuccessResponseBuilder Set the transformation data. This will set a new resource instance on the response builder depending on what type of data is provided.

보호된 메소드들

메소드 설명
parseTransformer ( Transformer | callable $transformer, Model $model ) : Transformer | callable Parse a transformer class and set relations.
resolveModel ( Model | array $data ) : Model Resolve a model instance from the data.
resolveNestedRelations ( Collection | Model $data ) : array Resolve eager loaded relations from the model including any nested relations.
resolveRelations ( Model $model ) : array Resolve eager loaded relations from the model.
resolveResourceKey ( Model $model, string $resourceKey = null ) : string Resolve the resource key from the model.
resolveSerializer ( League\Fractal\Serializer\SerializerAbstract | string $serializer ) : League\Fractal\Serializer\SerializerAbstract Resolve a serializer instance from the value.
resolveTransformer ( Model $model, Transformer | callable | null $transformer = null ) : Transformer | callable Resolve a transformer.
resolveTransformerFromModel ( Model $model ) : Transformer | callable Resolve a transformer from the model. If the model is not transformable, a closure based transformer will be created instead, from the model's fillable attributes.
serialize ( League\Fractal\Resource\ResourceInterface $resource ) : array Serialize the transformation data.

메소드 상세

__construct() 공개 메소드

SuccessResponseBuilder constructor.
public __construct ( Illuminate\Contracts\Routing\ResponseFactory | ResponseFactory $responseFactory, ResourceFactory $resourceFactory, League\Fractal\Manager $manager )
$responseFactory Illuminate\Contracts\Routing\ResponseFactory | Laravel\Lumen\Http\ResponseFactory
$resourceFactory Flugg\Responder\ResourceFactory
$manager League\Fractal\Manager

addMeta() 공개 메소드

Add data to the meta data appended to the response data.
public addMeta ( array $data ) : SuccessResponseBuilder
$data array
리턴 SuccessResponseBuilder

getManager() 공개 메소드

Get the Fractal manager responsible for transforming and serializing the data.
public getManager ( ) : League\Fractal\Manager
리턴 League\Fractal\Manager

getResource() 공개 메소드

Get the Fractal resource instance.
public getResource ( ) : League\Fractal\Resource\ResourceInterface
리턴 League\Fractal\Resource\ResourceInterface

include() 공개 메소드

Set the serializer used to serialize the resource data.
public include ( array | string $relations ) : SuccessResponseBuilder
$relations array | string
리턴 SuccessResponseBuilder

parseTransformer() 보호된 메소드

Parse a transformer class and set relations.
protected parseTransformer ( Transformer | callable $transformer, Model $model ) : Transformer | callable
$transformer Flugg\Responder\Transformer | callable
$model Illuminate\Database\Eloquent\Model
리턴 Flugg\Responder\Transformer | callable

resolveModel() 보호된 메소드

Resolve a model instance from the data.
protected resolveModel ( Model | array $data ) : Model
$data Illuminate\Database\Eloquent\Model | array
리턴 Illuminate\Database\Eloquent\Model

resolveNestedRelations() 보호된 메소드

Resolve eager loaded relations from the model including any nested relations.
protected resolveNestedRelations ( Collection | Model $data ) : array
$data Illuminate\Support\Collection | Illuminate\Database\Eloquent\Model
리턴 array

resolveRelations() 보호된 메소드

Resolve eager loaded relations from the model.
protected resolveRelations ( Model $model ) : array
$model Illuminate\Database\Eloquent\Model
리턴 array

resolveResourceKey() 보호된 메소드

Resolve the resource key from the model.
protected resolveResourceKey ( Model $model, string $resourceKey = null ) : string
$model Illuminate\Database\Eloquent\Model
$resourceKey string
리턴 string

resolveSerializer() 보호된 메소드

Resolve a serializer instance from the value.
protected resolveSerializer ( League\Fractal\Serializer\SerializerAbstract | string $serializer ) : League\Fractal\Serializer\SerializerAbstract
$serializer League\Fractal\Serializer\SerializerAbstract | string
리턴 League\Fractal\Serializer\SerializerAbstract

resolveTransformer() 보호된 메소드

Resolve a transformer.
protected resolveTransformer ( Model $model, Transformer | callable | null $transformer = null ) : Transformer | callable
$model Illuminate\Database\Eloquent\Model
$transformer Flugg\Responder\Transformer | callable | null
리턴 Flugg\Responder\Transformer | callable

resolveTransformerFromModel() 보호된 메소드

Resolve a transformer from the model. If the model is not transformable, a closure based transformer will be created instead, from the model's fillable attributes.
protected resolveTransformerFromModel ( Model $model ) : Transformer | callable
$model Illuminate\Database\Eloquent\Model
리턴 Flugg\Responder\Transformer | callable

serialize() 보호된 메소드

Serialize the transformation data.
protected serialize ( League\Fractal\Resource\ResourceInterface $resource ) : array
$resource League\Fractal\Resource\ResourceInterface
리턴 array

serializer() 공개 메소드

Set the serializer used to serialize the resource data.
public serializer ( League\Fractal\Serializer\SerializerAbstract | string $serializer ) : SuccessResponseBuilder
$serializer League\Fractal\Serializer\SerializerAbstract | string
리턴 SuccessResponseBuilder

setStatus() 공개 메소드

Set the HTTP status code for the response.
public setStatus ( integer $statusCode ) : ResponseBuilder
$statusCode integer
리턴 ResponseBuilder

toArray() 공개 메소드

Convert the response to an array.
public toArray ( ) : array
리턴 array

transform() 공개 메소드

Set the transformation data. This will set a new resource instance on the response builder depending on what type of data is provided.
public transform ( mixed | null $data = null, callable | string | null $transformer = null, string $resourceKey = null ) : SuccessResponseBuilder
$data mixed | null
$transformer callable | string | null
$resourceKey string
리턴 SuccessResponseBuilder

프로퍼티 상세

$manager 보호되어 있는 프로퍼티

The manager responsible for transforming and serializing data.
protected Manager,League\Fractal $manager
리턴 League\Fractal\Manager

$meta 보호되어 있는 프로퍼티

The meta data appended to the serialized data.
protected array $meta
리턴 array

$relations 보호되어 있는 프로퍼티

The included relations.
protected array $relations
리턴 array

$resource 보호되어 있는 프로퍼티

The Fractal resource instance containing the data and transformer.
protected ResourceInterface,League\Fractal\Resource $resource
리턴 League\Fractal\Resource\ResourceInterface

$resourceFactory 보호되어 있는 프로퍼티

The resource factory used to generate resource instances.
protected ResourceFactory,Flugg\Responder $resourceFactory
리턴 Flugg\Responder\ResourceFactory

$statusCode 보호되어 있는 프로퍼티

The HTTP status code for the response.
protected int $statusCode
리턴 integer