PHP Class Dingo\Api\Transformer\Adapter\Fractal

Inheritance: implements Dingo\Api\Contract\Transformer\Adapter
Show file Open project: dingo/api

Protected Properties

Property Type Description
$eagerLoading boolean Indicates if eager loading is enabled.
$fractal League\Fractal\Manager Fractal manager instance.
$includeKey string The include query string key.
$includeSeparator string The include separator.

Public Methods

Method Description
__construct ( League\Fractal\Manager $fractal, string $includeKey = 'include', string $includeSeparator = ',', boolean $eagerLoading = true ) : void Create a new fractal transformer instance.
disableEagerLoading ( ) : Fractal Disable eager loading.
enableEagerLoading ( ) : Fractal Enable eager loading.
getFractal ( ) : League\Fractal\Manager Get the underlying Fractal instance.
parseFractalIncludes ( Dingo\Api\Http\Request $request ) : void Parse the includes.
transform ( mixed $response, object $transformer, Dingo\Api\Transformer\Binding $binding, Dingo\Api\Http\Request $request ) : array Transform a response with a transformer.

Protected Methods

Method Description
createPaginatorAdapter ( Illuminate\Contracts\Pagination\Paginator $paginator ) : League\Fractal\Pagination\IlluminatePaginatorAdapter Create the Fractal paginator adapter.
createResource ( mixed $response, League\Fractal\TransformerAbstract $transformer, array $parameters ) : League\Fractal\Resource\Item | League\Fractal\Resource\Collection Create a Fractal resource instance.
mergeEagerLoads ( League\Fractal\TransformerAbstract $transformer, string | array $requestedIncludes ) : array Get includes as their array keys for eager loading.
shouldEagerLoad ( mixed $response ) : boolean Eager loading is only performed when the response is or contains an Eloquent collection and eager loading is enabled.

Method Details

__construct() public method

Create a new fractal transformer instance.
public __construct ( League\Fractal\Manager $fractal, string $includeKey = 'include', string $includeSeparator = ',', boolean $eagerLoading = true ) : void
$fractal League\Fractal\Manager
$includeKey string
$includeSeparator string
$eagerLoading boolean
return void

createPaginatorAdapter() protected method

Create the Fractal paginator adapter.
protected createPaginatorAdapter ( Illuminate\Contracts\Pagination\Paginator $paginator ) : League\Fractal\Pagination\IlluminatePaginatorAdapter
$paginator Illuminate\Contracts\Pagination\Paginator
return League\Fractal\Pagination\IlluminatePaginatorAdapter

createResource() protected method

Create a Fractal resource instance.
protected createResource ( mixed $response, League\Fractal\TransformerAbstract $transformer, array $parameters ) : League\Fractal\Resource\Item | League\Fractal\Resource\Collection
$response mixed
$transformer League\Fractal\TransformerAbstract
$parameters array
return League\Fractal\Resource\Item | League\Fractal\Resource\Collection

disableEagerLoading() public method

Disable eager loading.
public disableEagerLoading ( ) : Fractal
return Fractal

enableEagerLoading() public method

Enable eager loading.
public enableEagerLoading ( ) : Fractal
return Fractal

getFractal() public method

Get the underlying Fractal instance.
public getFractal ( ) : League\Fractal\Manager
return League\Fractal\Manager

mergeEagerLoads() protected method

Get includes as their array keys for eager loading.
protected mergeEagerLoads ( League\Fractal\TransformerAbstract $transformer, string | array $requestedIncludes ) : array
$transformer League\Fractal\TransformerAbstract
$requestedIncludes string | array
return array

parseFractalIncludes() public method

Parse the includes.
public parseFractalIncludes ( Dingo\Api\Http\Request $request ) : void
$request Dingo\Api\Http\Request
return void

shouldEagerLoad() protected method

Eager loading is only performed when the response is or contains an Eloquent collection and eager loading is enabled.
protected shouldEagerLoad ( mixed $response ) : boolean
$response mixed
return boolean

transform() public method

Transform a response with a transformer.
public transform ( mixed $response, object $transformer, Dingo\Api\Transformer\Binding $binding, Dingo\Api\Http\Request $request ) : array
$response mixed
$transformer object
$binding Dingo\Api\Transformer\Binding
$request Dingo\Api\Http\Request
return array

Property Details

$eagerLoading protected property

Indicates if eager loading is enabled.
protected bool $eagerLoading
return boolean

$fractal protected property

Fractal manager instance.
protected Manager,League\Fractal $fractal
return League\Fractal\Manager

$includeKey protected property

The include query string key.
protected string $includeKey
return string

$includeSeparator protected property

The include separator.
protected string $includeSeparator
return string