1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 00:53:10 +01:00
invoiceninja/app/Transformers/EntityTransformer.php

55 lines
1.3 KiB
PHP
Raw Normal View History

2019-03-28 03:36:36 +01:00
<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2019-05-11 05:32:07 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 05:32:07 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
2019-03-28 03:36:36 +01:00
2019-03-28 22:34:58 +01:00
namespace App\Transformers;
2019-03-28 03:36:36 +01:00
use League\Fractal\TransformerAbstract;
class EntityTransformer extends TransformerAbstract
{
protected $serializer;
2019-03-28 22:34:58 +01:00
const API_SERIALIZER_ARRAY = 'array';
const API_SERIALIZER_JSON = 'json';
2019-03-28 03:36:36 +01:00
public function __construct($serializer = null)
{
$this->serializer = $serializer;
}
protected function includeCollection($data, $transformer, $entityType)
{
2019-03-28 22:34:58 +01:00
if ($this->serializer && $this->serializer != self::API_SERIALIZER_JSON) {
2019-03-28 03:36:36 +01:00
$entityType = null;
}
return $this->collection($data, $transformer, $entityType);
}
protected function includeItem($data, $transformer, $entityType)
{
2019-03-28 22:34:58 +01:00
if ($this->serializer && $this->serializer != self::API_SERIALIZER_JSON) {
2019-03-28 03:36:36 +01:00
$entityType = null;
}
return $this->item($data, $transformer, $entityType);
}
public function getDefaultIncludes()
{
return $this->defaultIncludes;
}
protected function getDefaults($entity)
{
}
}