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:
Toby Zerner
2015-03-24 15:04:24 +10:30
parent 536281e273
commit a62e04f956
36 changed files with 342 additions and 503 deletions

View File

@ -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);
}
}