1
0
Fork 0
pixelfed/app/Transformer/Api/ResultsTransformer.php

43 lines
768 B
PHP
Raw Normal View History

2018-12-31 04:26:37 +00:00
<?php
namespace App\Transformer\Api;
use League\Fractal;
class ResultsTransformer extends Fractal\TransformerAbstract
{
protected $defaultIncludes = [
2019-01-12 20:58:35 +00:00
'accounts',
'statuses',
'hashtags',
2018-12-31 04:26:37 +00:00
];
2019-01-12 20:58:35 +00:00
public function transform($results)
2018-12-31 04:26:37 +00:00
{
return [
'accounts' => [],
'statuses' => [],
'hashtags' => []
];
}
2019-01-12 20:58:35 +00:00
public function includeAccounts($results)
{
$accounts = $results->accounts;
return $this->collection($accounts, new AccountTransformer());
}
public function includeStatuses($results)
{
$statuses = $results->statuses;
return $this->collection($statuses, new StatusTransformer());
}
public function includeTags($results)
{
2022-05-17 10:41:01 +00:00
$hashtags = $results->hashtags;
2019-01-12 20:58:35 +00:00
return $this->collection($hashtags, new HashtagTransformer());
}
2018-12-31 04:26:37 +00:00
}