1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00
invoiceninja/app/Ninja/Transformers/EntityTransformer.php

41 lines
1.0 KiB
PHP
Raw Normal View History

2015-11-08 22:12:50 +01:00
<?php namespace App\Ninja\Transformers;
use App\Models\Account;
2015-11-27 13:55:28 +01:00
use App\Models\Client;
2015-11-08 22:12:50 +01:00
use League\Fractal\TransformerAbstract;
class EntityTransformer extends TransformerAbstract
{
protected $account;
2015-11-27 13:55:28 +01:00
protected $serializer;
2015-11-08 22:12:50 +01:00
2015-11-27 13:55:28 +01:00
public function __construct(Account $account = null, $serializer = null)
2015-11-08 22:12:50 +01:00
{
$this->account = $account;
2015-11-27 13:55:28 +01:00
$this->serializer = $serializer;
}
protected function includeCollection($data, $transformer, $entityType)
{
if ($this->serializer && $this->serializer != API_SERIALIZER_JSON) {
$entityType = null;
}
return $this->collection($data, $transformer, $entityType);
}
protected function includeItem($data, $transformer, $entityType)
{
if ($this->serializer && $this->serializer != API_SERIALIZER_JSON) {
$entityType = null;
}
return $this->item($data, $transformer, $entityType);
2015-11-08 22:12:50 +01:00
}
2015-12-27 12:08:58 +01:00
protected function getTimestamp($date)
{
return $date ? $date->getTimestamp() : null;
}
2015-11-08 22:12:50 +01:00
}