invoiceninja/app/Transformers/EntityTransformer.php

47 lines
1 KiB
PHP
Raw Normal View History

2019-03-28 13:36:36 +11:00
<?php
2019-03-29 08:34:58 +11:00
namespace App\Transformers;
2019-03-28 13:36:36 +11:00
use League\Fractal\TransformerAbstract;
class EntityTransformer extends TransformerAbstract
{
protected $serializer;
2019-03-29 08:34:58 +11:00
const API_SERIALIZER_ARRAY = 'array';
const API_SERIALIZER_JSON = 'json';
2019-03-28 13:36:36 +11:00
public function __construct($serializer = null)
{
$this->serializer = $serializer;
}
protected function includeCollection($data, $transformer, $entityType)
{
2019-03-29 08:34:58 +11:00
if ($this->serializer && $this->serializer != self::API_SERIALIZER_JSON) {
2019-03-28 13:36:36 +11:00
$entityType = null;
}
return $this->collection($data, $transformer, $entityType);
}
protected function includeItem($data, $transformer, $entityType)
{
2019-03-29 08:34:58 +11:00
if ($this->serializer && $this->serializer != self::API_SERIALIZER_JSON) {
2019-03-28 13:36:36 +11:00
$entityType = null;
}
return $this->item($data, $transformer, $entityType);
}
public function getDefaultIncludes()
{
return $this->defaultIncludes;
}
protected function getDefaults($entity)
{
}
}