1
0
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:
Toby Zerner
2015-07-01 22:34:11 +09:30
parent c588e55070
commit 659ca692e3
15 changed files with 239 additions and 217 deletions

View File

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

View File

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

View File

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