PHP Класс Flugg\Responder\Http\SuccessResponseBuilder

Автор: Alexander Tømmerås ([email protected])
Наследование: extends ResponseBuilder
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$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