mirror of
https://github.com/flarum/core.git
synced 2025-07-23 09:41:26 +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:
@@ -10,18 +10,27 @@ class ActivityType implements ExtenderInterface
|
||||
|
||||
protected $serializer;
|
||||
|
||||
public function __construct($class, $serializer)
|
||||
public function __construct($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function subjectSerializer($serializer)
|
||||
{
|
||||
$this->serializer = $serializer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$class = $this->class;
|
||||
$type = $class::getType();
|
||||
|
||||
Activity::setSubjectModel($class::getType(), $class::getSubjectModel());
|
||||
Activity::setSubjectModel($type, $class::getSubjectModel());
|
||||
|
||||
ActivitySerializer::$subjects[$class::getType()] = $this->serializer;
|
||||
if ($this->serializer) {
|
||||
ActivitySerializer::setSubjectSerializer($type, $this->serializer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,6 @@ class DiscussionGambit implements ExtenderInterface
|
||||
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$container->make('events')->listen('Flarum\Core\Events\RegisterDiscussionGambits', function ($event) {
|
||||
$event->gambits->add($this->class);
|
||||
});
|
||||
$container->make('flarum.discussionGambits')[] = $this->class;
|
||||
}
|
||||
}
|
||||
|
@@ -13,10 +13,16 @@ class NotificationType implements ExtenderInterface
|
||||
|
||||
protected $enabled = [];
|
||||
|
||||
public function __construct($class, $serializer)
|
||||
public function __construct($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function subjectSerializer($serializer)
|
||||
{
|
||||
$this->serializer = $serializer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function enableByDefault($method)
|
||||
|
Reference in New Issue
Block a user