1
0
mirror of https://github.com/flarum/core.git synced 2025-10-10 06:24:26 +02:00
Files
php-flarum/src/Api/Serializers/CurrentUserSerializer.php
2015-08-27 01:40:18 +02:00

33 lines
858 B
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Api\Serializers;
class CurrentUserSerializer extends UserSerializer
{
/**
* {@inheritdoc}
*/
protected function getDefaultAttributes($user)
{
$attributes = parent::getDefaultAttributes($user);
if ($user->id == $this->actor->id) {
$attributes += [
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
'unreadNotificationsCount' => $user->getUnreadNotificationsCount(),
'preferences' => $user->preferences
];
}
return $attributes;
}
}