2015-02-24 18:03:18 +08:00
|
|
|
<?php namespace Flarum\Core;
|
|
|
|
|
2015-07-16 06:10:52 +08:00
|
|
|
use Flarum\Core\Settings\MemoryCacheSettingsRepository;
|
2015-07-16 05:54:56 +08:00
|
|
|
use Flarum\Core\Settings\DatabaseSettingsRepository;
|
2015-07-04 10:54:48 +08:00
|
|
|
use Flarum\Core\Users\User;
|
2015-05-15 15:35:46 +08:00
|
|
|
use Flarum\Support\ServiceProvider;
|
2015-07-01 21:04:11 +08:00
|
|
|
use Flarum\Extend;
|
2015-02-24 18:03:18 +08:00
|
|
|
|
|
|
|
class CoreServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap the application events.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-07-01 21:04:11 +08:00
|
|
|
public function boot()
|
2015-02-24 18:03:18 +08:00
|
|
|
{
|
2015-02-25 13:04:02 +08:00
|
|
|
$this->loadViewsFrom(__DIR__.'/../../views', 'flarum');
|
2015-02-24 18:03:18 +08:00
|
|
|
|
2015-07-04 10:54:48 +08:00
|
|
|
$this->app->make('Illuminate\Contracts\Bus\Dispatcher')->mapUsing(function ($command) {
|
|
|
|
return get_class($command).'Handler@handle';
|
|
|
|
});
|
2015-05-11 10:41:19 +08:00
|
|
|
|
2015-07-04 10:54:48 +08:00
|
|
|
Forum::allow('*', function (Forum $forum, User $user, $action) {
|
|
|
|
return $user->hasPermission('forum.'.$action) ?: null;
|
2015-02-24 18:03:18 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the service provider.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2015-07-16 05:54:56 +08:00
|
|
|
$this->app->singleton('Flarum\Core\Settings\SettingsRepository', function() {
|
2015-07-16 06:10:52 +08:00
|
|
|
return new MemoryCacheSettingsRepository(
|
2015-07-16 05:54:56 +08:00
|
|
|
new DatabaseSettingsRepository(
|
|
|
|
$this->app->make('Illuminate\Database\ConnectionInterface')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-07-04 10:54:48 +08:00
|
|
|
$this->app->singleton('flarum.forum', 'Flarum\Core\Forum');
|
2015-02-24 18:03:18 +08:00
|
|
|
|
2015-07-01 21:04:11 +08:00
|
|
|
// TODO: probably use Illuminate's AggregateServiceProvider
|
|
|
|
// functionality, because it includes the 'provides' stuff.
|
|
|
|
$this->app->register('Flarum\Core\Activity\ActivityServiceProvider');
|
2015-07-04 10:54:48 +08:00
|
|
|
$this->app->register('Flarum\Core\Discussions\DiscussionsServiceProvider');
|
2015-07-01 21:04:11 +08:00
|
|
|
$this->app->register('Flarum\Core\Formatter\FormatterServiceProvider');
|
|
|
|
$this->app->register('Flarum\Core\Notifications\NotificationsServiceProvider');
|
2015-07-04 10:54:48 +08:00
|
|
|
$this->app->register('Flarum\Core\Posts\PostsServiceProvider');
|
|
|
|
$this->app->register('Flarum\Core\Users\UsersServiceProvider');
|
2015-02-24 18:03:18 +08:00
|
|
|
}
|
|
|
|
}
|