mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 23:29:57 +08:00
Upgrade to JSON-API RC3 + latest version of tobscure/json-api
Note: npm source for ember-json-api changed to a fork, but I still had to apply a custom change to get polymorphic relationships to work (see https://github.com/kurko/ember-json-api/pull/71#issuecomment-85257281)
This commit is contained in:
@ -1,17 +1,10 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserBasicSerializer extends BaseSerializer
|
||||
{
|
||||
/**
|
||||
* The name to use for Flarum events.
|
||||
* @var string
|
||||
*/
|
||||
protected static $eventName = 'UserBasic';
|
||||
|
||||
/**
|
||||
* The resource type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'users';
|
||||
@ -22,29 +15,13 @@ class UserBasicSerializer extends BaseSerializer
|
||||
* @param User $user The User model to serialize.
|
||||
* @return array
|
||||
*/
|
||||
protected function attributes(User $user)
|
||||
protected function attributes($user)
|
||||
{
|
||||
$attributes = [
|
||||
'id' => (int) $user->id,
|
||||
'username' => $user->username,
|
||||
'avatarUrl' => $user->avatar_url
|
||||
];
|
||||
|
||||
return $this->attributesEvent($user, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL templates where this resource and its related resources can
|
||||
* be accessed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function href()
|
||||
{
|
||||
$href = [
|
||||
'users' => $this->action('UsersController@show', ['id' => '{users.id}'])
|
||||
];
|
||||
|
||||
return $this->hrefEvent($href);
|
||||
return $this->extendAttributes($user, $attributes);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user