mirror of
https://github.com/flarum/framework.git
synced 2024-11-24 00:30:47 +08:00
Add shortcut API to serialize attributes
This commit is contained in:
parent
9559ac1bb6
commit
a4d3345b99
|
@ -5,6 +5,7 @@ use Illuminate\Contracts\Events\Dispatcher;
|
|||
use Flarum\Core\Models\Notification;
|
||||
use Flarum\Core\Models\User;
|
||||
use Flarum\Core\Models\Post;
|
||||
use Closure;
|
||||
|
||||
class ServiceProvider extends IlluminateServiceProvider
|
||||
{
|
||||
|
@ -75,4 +76,13 @@ class ServiceProvider extends IlluminateServiceProvider
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function serializeAttributes($serializer, Closure $callback)
|
||||
{
|
||||
$this->app['events']->listen('Flarum\Api\Events\SerializeAttributes', function ($event) use ($serializer, $callback) {
|
||||
if ($event->serializer instanceof $serializer) {
|
||||
$callback($event->attributes, $event->model);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user