mirror of
https://github.com/flarum/core.git
synced 2025-07-25 18:51:40 +02:00
This will likely have to be reverted, to make things like $this->app->extend() work reasonably well in extensions' service providers. For now, since we fetch the enabled extensions from the config, there is no other way for us to guarantee that the config is already available.
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php namespace Flarum\Support\Extensions;
|
|
|
|
use Flarum\Core;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class ExtensionsServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register the service provider.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Boot the service provider.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
// Extensions will not be registered if Flarum is not installed yet
|
|
if (!Core::isInstalled()) {
|
|
return;
|
|
}
|
|
|
|
$config = $this->app->make('Flarum\Core\Settings\SettingsRepository')->get('extensions_enabled');
|
|
$extensions = json_decode($config, true);
|
|
$providers = [];
|
|
|
|
foreach ($extensions as $extension) {
|
|
if (file_exists($file = public_path().'/extensions/'.$extension.'/bootstrap.php') ||
|
|
file_exists($file = base_path().'/extensions/'.$extension.'/bootstrap.php')) {
|
|
$providers[$extension] = require $file;
|
|
}
|
|
}
|
|
|
|
// @todo store $providers somewhere (in Core?) so that extensions can talk to each other
|
|
}
|
|
}
|