-
-
Save dansup/7ed5d81949cd167d56cbb7214746695d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 300, | |
"uri": "https:\/\/pixelfed.dev\/p\/dan\/300", | |
"url": "https:\/\/pixelfed.dev\/p\/dan\/300", | |
"in_reply_to_id": null, | |
"in_reply_to_account_id": null, | |
"reblog": null, | |
"content": "<p>@<a class=\"u-url mention\" href=\"https:\/\/pixelfed.dev\/test\" rel=\"external nofollow noopener\" target=\"_blank\">test<\/a> this is a test. <a href=\"https:\/\/pixelfed.dev\/discover\/tags\/pixelfed?src=hash\" title=\"#pixelfed\" class=\"u-url hashtag\" rel=\"external nofollow noopener\">#pixelfed<\/a> <a href=\"https:\/\/pixelfed.dev\/discover\/tags\/dev?src=hash\" title=\"#dev\" class=\"u-url hashtag\" rel=\"external nofollow noopener\">#dev<\/a><\/p>", | |
"created_at": "2018-07-01T00:20:19+00:00", | |
"emojis": [], | |
"reblogs_count": 0, | |
"favourites_count": 0, | |
"reblogged": false, | |
"favourited": false, | |
"muted": null, | |
"sensitive": false, | |
"spoiler_text": "", | |
"visibility": "public", | |
"application": null, | |
"language": null, | |
"pinned": null, | |
"account": { | |
"id": 1, | |
"username": "dan", | |
"acct": "dan", | |
"display_name": "Daniel", | |
"locked": false, | |
"created_at": "2018-06-08T02:31:38+00:00", | |
"followers_count": 7, | |
"following_count": 13, | |
"statuses_count": 42, | |
"note": null, | |
"url": "https:\/\/pixelfed.dev\/dan", | |
"avatar": "https:\/\/pixelfed.dev\/storage\/avatars\/000\/000\/000\/001\/avatar.svg", | |
"avatar_static": "https:\/\/pixelfed.dev\/storage\/avatars\/000\/000\/000\/001\/avatar.svg", | |
"header": "", | |
"header_static": "", | |
"moved": null, | |
"fields": null, | |
"bot": null | |
}, | |
"mentions": [ | |
{ | |
"id": 2, | |
"url": "https:\/\/pixelfed.dev\/test", | |
"username": "test", | |
"acct": "test" | |
} | |
], | |
"media_attachments": [ | |
{ | |
"id": 227, | |
"type": "image", | |
"url": "https:\/\/pixelfed.dev\/storage\/m\/aaa96670d7158a02dc23363ceda0dc59f94759db\/a11b671bab56adfe55f5dd6c440bcbee30e96662\/nNkwnrtcFXNStoXD1ZPx2ZzztEuYhV36TWX0kAKD.jpeg", | |
"remote_url": null, | |
"preview_url": "https:\/\/pixelfed.dev\/storage\/m\/aaa96670d7158a02dc23363ceda0dc59f94759db\/a11b671bab56adfe55f5dd6c440bcbee30e96662\/nNkwnrtcFXNStoXD1ZPx2ZzztEuYhV36TWX0kAKD_thumb.jpeg", | |
"text_url": null, | |
"meta": null, | |
"description": null | |
} | |
], | |
"tags": [ | |
{ | |
"name": "pixelfed", | |
"url": "https:\/\/pixelfed.dev\/discover\/tags\/pixelfed" | |
} | |
] | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Transformer\Api; | |
use App\Status; | |
use League\Fractal; | |
class StatusTransformer extends Fractal\TransformerAbstract | |
{ | |
protected $defaultIncludes = [ | |
'account', | |
'mentions', | |
'media_attachments', | |
'tags' | |
]; | |
public function transform(Status $status) | |
{ | |
return [ | |
'id' => $status->id, | |
'uri' => $status->url(), | |
'url' => $status->url(), | |
'in_reply_to_id' => $status->in_reply_to_id, | |
'in_reply_to_account_id' => $status->in_reply_to_profile_id, | |
// TODO: fixme | |
'reblog' => null, | |
'content' => "<p>$status->rendered</p>", | |
'created_at' => $status->created_at->format('c'), | |
'emojis' => [], | |
'reblogs_count' => $status->shares()->count(), | |
'favourites_count' => $status->likes()->count(), | |
'reblogged' => $status->shared(), | |
'favourited' => $status->liked(), | |
'muted' => null, | |
'sensitive' => (bool) $status->is_nsfw, | |
'spoiler_text' => '', | |
'visibility' => $status->visibility, | |
'application' => null, | |
'language' => null, | |
'pinned' => null | |
]; | |
} | |
public function includeAccount(Status $status) | |
{ | |
$account = $status->profile; | |
return $this->item($account, new AccountTransformer); | |
} | |
public function includeMentions(Status $status) | |
{ | |
$mentions = $status->mentions; | |
return $this->collection($mentions, new MentionTransformer); | |
} | |
public function includeMediaAttachments(Status $status) | |
{ | |
$media = $status->media; | |
return $this->collection($media, new MediaTransformer); | |
} | |
public function includeTags(Status $status) | |
{ | |
$tags = $status->hashtags; | |
return $this->collection($tags, new HashtagTransformer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment