1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/app/Transformers/EntityTransformer.php

56 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
*
2022-04-27 05:20:41 +02:00
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 05:32:07 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2019-05-11 05:32:07 +02:00
*/
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';
2019-03-28 22:34:58 +01:00
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)
{
}
}