mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 13:36:10 +08:00
Split up old CoreServiceProvider
This commit is contained in:
parent
ede7e96282
commit
6e8b8ac357
30
framework/core/src/BusServiceProvider.php
Normal file
30
framework/core/src/BusServiceProvider.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?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;
|
||||||
|
|
||||||
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
class BusServiceProvider extends AbstractServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->app->make('Illuminate\Contracts\Bus\Dispatcher')->mapUsing(function ($command) {
|
||||||
|
return get_class($command).'Handler@handle';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
29
framework/core/src/Discussion/DiscussionServiceProvider.php
Normal file
29
framework/core/src/Discussion/DiscussionServiceProvider.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?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\Discussion;
|
||||||
|
|
||||||
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
|
||||||
|
class DiscussionServiceProvider extends AbstractServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$events = $this->app->make('events');
|
||||||
|
|
||||||
|
$events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater');
|
||||||
|
$events->subscribe('Flarum\Discussion\DiscussionPolicy');
|
||||||
|
$events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier');
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,4 +30,14 @@ class ExtensionServiceProvider extends AbstractServiceProvider
|
||||||
$this->app->call($bootstrapper);
|
$this->app->call($bootstrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$events = $this->app->make('events');
|
||||||
|
|
||||||
|
$events->subscribe('Flarum\Extension\DefaultLanguagePackGuard');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,16 @@ abstract class AbstractServer
|
||||||
$config->set('mail.username', $settings->get('mail_username'));
|
$config->set('mail.username', $settings->get('mail_username'));
|
||||||
$config->set('mail.password', $settings->get('mail_password'));
|
$config->set('mail.password', $settings->get('mail_password'));
|
||||||
|
|
||||||
$app->register('Flarum\Core\CoreServiceProvider');
|
$app->register('Flarum\BusServiceProvider');
|
||||||
|
|
||||||
|
$app->register('Flarum\Discussion\DiscussionServiceProvider');
|
||||||
|
$app->register('Flarum\Formatter\FormatterServiceProvider');
|
||||||
|
$app->register('Flarum\Group\GroupServiceProvider');
|
||||||
|
$app->register('Flarum\Notification\NotificationServiceProvider');
|
||||||
|
$app->register('Flarum\Post\PostServiceProvider');
|
||||||
|
$app->register('Flarum\Search\SearchServiceProvider');
|
||||||
|
$app->register('Flarum\User\UserServiceProvider');
|
||||||
|
|
||||||
$app->register('Flarum\Api\ApiServiceProvider');
|
$app->register('Flarum\Api\ApiServiceProvider');
|
||||||
$app->register('Flarum\Forum\ForumServiceProvider');
|
$app->register('Flarum\Forum\ForumServiceProvider');
|
||||||
$app->register('Flarum\Admin\AdminServiceProvider');
|
$app->register('Flarum\Admin\AdminServiceProvider');
|
||||||
|
|
25
framework/core/src/Frontend/FrontendServiceProvider.php
Normal file
25
framework/core/src/Frontend/FrontendServiceProvider.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?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\Frontend;
|
||||||
|
|
||||||
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
|
||||||
|
class FrontendServiceProvider extends AbstractServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->loadViewsFrom(__DIR__.'/../../views', 'flarum');
|
||||||
|
}
|
||||||
|
}
|
26
framework/core/src/Group/GroupServiceProvider.php
Normal file
26
framework/core/src/Group/GroupServiceProvider.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?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\Group;
|
||||||
|
|
||||||
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
|
||||||
|
class GroupServiceProvider extends AbstractServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$events = $this->app->make('events');
|
||||||
|
$events->subscribe('Flarum\Group\GroupPolicy');
|
||||||
|
}
|
||||||
|
}
|
|
@ -171,7 +171,13 @@ class InstallCommand extends AbstractCommand
|
||||||
|
|
||||||
$this->writeSettings();
|
$this->writeSettings();
|
||||||
|
|
||||||
$this->application->register('Flarum\Core\CoreServiceProvider');
|
$this->application->register('Flarum\Formatter\FormatterServiceProvider');
|
||||||
|
$this->application->register('Flarum\Discussion\DiscussionServiceProvider');
|
||||||
|
$this->application->register('Flarum\Group\GroupServiceProvider');
|
||||||
|
$this->application->register('Flarum\Notification\NotificationServiceProvider');
|
||||||
|
$this->application->register('Flarum\Search\SearchServiceProvider');
|
||||||
|
$this->application->register('Flarum\Post\PostServiceProvider');
|
||||||
|
$this->application->register('Flarum\User\UserServiceProvider');
|
||||||
|
|
||||||
$this->seedGroups();
|
$this->seedGroups();
|
||||||
$this->seedPermissions();
|
$this->seedPermissions();
|
||||||
|
|
47
framework/core/src/Post/PostServiceProvider.php
Normal file
47
framework/core/src/Post/PostServiceProvider.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?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\Post;
|
||||||
|
|
||||||
|
use Flarum\Event\ConfigurePostTypes;
|
||||||
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
|
||||||
|
class PostServiceProvider extends AbstractServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
CommentPost::setFormatter($this->app->make('flarum.formatter'));
|
||||||
|
|
||||||
|
$this->registerPostTypes();
|
||||||
|
|
||||||
|
$events = $this->app->make('events');
|
||||||
|
$events->subscribe('Flarum\Post\PostPolicy');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerPostTypes()
|
||||||
|
{
|
||||||
|
$models = [
|
||||||
|
'Flarum\Post\CommentPost',
|
||||||
|
'Flarum\Post\DiscussionRenamedPost'
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->app->make('events')->fire(
|
||||||
|
new ConfigurePostTypes($models)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($models as $model) {
|
||||||
|
Post::setModel($model::$type, $model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,20 +9,14 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core;
|
namespace Flarum\User;
|
||||||
|
|
||||||
use Flarum\Post\CommentPost;
|
|
||||||
use Flarum\Event\ConfigurePostTypes;
|
|
||||||
use Flarum\Event\ConfigureUserPreferences;
|
use Flarum\Event\ConfigureUserPreferences;
|
||||||
use Flarum\Event\GetPermission;
|
use Flarum\Event\GetPermission;
|
||||||
use Flarum\Foundation\AbstractServiceProvider;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
use Flarum\Post\Post;
|
|
||||||
use Flarum\User\Gate;
|
|
||||||
use Flarum\User\User;
|
|
||||||
use Illuminate\Contracts\Container\Container;
|
use Illuminate\Contracts\Container\Container;
|
||||||
use RuntimeException;
|
|
||||||
|
|
||||||
class CoreServiceProvider extends AbstractServiceProvider
|
class UserServiceProvider extends AbstractServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -39,10 +33,6 @@ class CoreServiceProvider extends AbstractServiceProvider
|
||||||
$this->app->alias('flarum.gate', 'Flarum\User\Gate');
|
$this->app->alias('flarum.gate', 'Flarum\User\Gate');
|
||||||
|
|
||||||
$this->registerAvatarsFilesystem();
|
$this->registerAvatarsFilesystem();
|
||||||
|
|
||||||
$this->app->register('Flarum\Notification\Notification\NotificationServiceProvider');
|
|
||||||
$this->app->register('Flarum\Search\SearchServiceProvider');
|
|
||||||
$this->app->register('Flarum\Formatter\FormatterServiceProvider');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function registerAvatarsFilesystem()
|
protected function registerAvatarsFilesystem()
|
||||||
|
@ -69,12 +59,6 @@ class CoreServiceProvider extends AbstractServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->loadViewsFrom(__DIR__.'/../../views', 'flarum');
|
|
||||||
|
|
||||||
$this->app->make('Illuminate\Contracts\Bus\Dispatcher')->mapUsing(function ($command) {
|
|
||||||
return get_class($command).'Handler@handle';
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->app->make('flarum.gate')->before(function (User $actor, $ability, $model = null) {
|
$this->app->make('flarum.gate')->before(function (User $actor, $ability, $model = null) {
|
||||||
// Fire an event so that core and extension policies can hook into
|
// Fire an event so that core and extension policies can hook into
|
||||||
// this permission query and explicitly grant or deny the
|
// this permission query and explicitly grant or deny the
|
||||||
|
@ -97,46 +81,19 @@ class CoreServiceProvider extends AbstractServiceProvider
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->registerPostTypes();
|
|
||||||
|
|
||||||
CommentPost::setFormatter($this->app->make('flarum.formatter'));
|
|
||||||
|
|
||||||
User::setHasher($this->app->make('hash'));
|
User::setHasher($this->app->make('hash'));
|
||||||
User::setGate($this->app->make('flarum.gate'));
|
User::setGate($this->app->make('flarum.gate'));
|
||||||
|
|
||||||
$events = $this->app->make('events');
|
$events = $this->app->make('events');
|
||||||
|
|
||||||
$events->subscribe('Flarum\Core\Listener\SelfDemotionGuard');
|
$events->subscribe('Flarum\Core\Listener\SelfDemotionGuard');
|
||||||
$events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater');
|
|
||||||
$events->subscribe('Flarum\User\UserMetadataUpdater');
|
|
||||||
$events->subscribe('Flarum\Extension\DefaultLanguagePackGuard');
|
|
||||||
$events->subscribe('Flarum\User\EmailConfirmationMailer');
|
$events->subscribe('Flarum\User\EmailConfirmationMailer');
|
||||||
$events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier');
|
$events->subscribe('Flarum\User\UserMetadataUpdater');
|
||||||
|
|
||||||
$events->subscribe('Flarum\Discussion\DiscussionPolicy');
|
|
||||||
$events->subscribe('Flarum\Group\GroupPolicy');
|
|
||||||
$events->subscribe('Flarum\Post\PostPolicy');
|
|
||||||
$events->subscribe('Flarum\User\UserPolicy');
|
$events->subscribe('Flarum\User\UserPolicy');
|
||||||
|
|
||||||
$events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']);
|
$events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerPostTypes()
|
|
||||||
{
|
|
||||||
$models = [
|
|
||||||
'Flarum\Post\CommentPost',
|
|
||||||
'Flarum\Post\DiscussionRenamedPost'
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->app->make('events')->fire(
|
|
||||||
new ConfigurePostTypes($models)
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($models as $model) {
|
|
||||||
Post::setModel($model::$type, $model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ConfigureUserPreferences $event
|
* @param ConfigureUserPreferences $event
|
||||||
*/
|
*/
|
Loading…
Reference in New Issue
Block a user