mirror of
https://github.com/flarum/core.git
synced 2025-07-23 17:51:24 +02:00
Refactor CoreServiceProvider
A good start I think, but still some work to do. If we go ahead with https://github.com/flarum/core/issues/132#issuecomment-117507974 (which I am in favour of), we can extract the entity-related stuff into some smaller service providers (e.g. discussion repo, an event listener, permissions, and gambits stuff could all go in Flarum\Core\Discussions\DiscussionsServiceProvider).
This commit is contained in:
@@ -22,6 +22,8 @@ class ApiServiceProvider extends ServiceProvider
|
||||
return new UrlGenerator($this->app->make('flarum.api.routes'));
|
||||
}
|
||||
);
|
||||
|
||||
$this->app->register('Flarum\Locale\LocaleServiceProvider');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,9 +3,7 @@
|
||||
class ActivitySerializer extends BaseSerializer
|
||||
{
|
||||
/**
|
||||
* The resource type.
|
||||
*
|
||||
* @var string
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $type = 'activity';
|
||||
|
||||
@@ -15,10 +13,7 @@ class ActivitySerializer extends BaseSerializer
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $subjects = [
|
||||
'posted' => 'Flarum\Api\Serializers\PostBasicSerializer',
|
||||
'joined' => 'Flarum\Api\Serializers\UserBasicSerializer'
|
||||
];
|
||||
protected static $subjectSerializers = [];
|
||||
|
||||
/**
|
||||
* Serialize attributes of an Activity model for JSON output.
|
||||
@@ -52,4 +47,9 @@ class ActivitySerializer extends BaseSerializer
|
||||
return static::$subjects[$activity->type];
|
||||
});
|
||||
}
|
||||
|
||||
public static function setSubjectSerializer($type, $serializer)
|
||||
{
|
||||
static::$subjectSerializers[$type] = $serializer;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user