} if (Core::isInstalled()) { $settings = $app->make('Flarum\\Core\\Settings\\SettingsRepository'); $app->register(new \Flarum\Core\CoreServiceProvider($app)); $config->set('mail.driver', Core::config('mail_driver')); $config->set('mail.host', Core::config('mail_host')); $config->set('mail.port', Core::config('mail_port')); $config->set('mail.from.address', Core::config('mail_from')); $config->set('mail.from.name', Core::config('forum_title')); $config->set('mail.encryption', Core::config('mail_encryption')); $config->set('mail.username', Core::config('mail_username')); $config->set('mail.password', Core::config('mail_password')); // Register extensions and tell them to listen for events $app->register(new \Flarum\Support\ExtensionsServiceProvider($app)); } $app->boot(); // If the version stored in the database doesn't match the version of the // code, then run the upgrade script (migrations). This is temporary - a // proper, more secure upgrade method is planned. if (Core::isInstalled() && $settings->get('version') !== $app::VERSION) { $input = new \Symfony\Component\Console\Input\StringInput(''); $output = new \Symfony\Component\Console\Output\BufferedOutput(); app('Flarum\\Console\\UpgradeCommand')->run($input, $output); $settings->set('version', $app::VERSION); app('flarum.formatter')->flush(); $forum = app('Flarum\\Forum\\Actions\\ClientAction'); $forum->flushAssets(); $admin = app('Flarum\\Admin\\Actions\\ClientAction'); $admin->flushAssets(); } return $app;
/** * Register the service provider. * * @return void */ public function register() { $this->app->singleton('flarum.db', function () { $factory = new ConnectionFactory($this->app); $connection = $factory->make($this->app->make('flarum.config')['database']); $connection->setEventDispatcher($this->app->make('Illuminate\\Contracts\\Events\\Dispatcher')); $connection->setFetchMode(PDO::FETCH_CLASS); return $connection; }); $this->app->alias('flarum.db', 'Illuminate\\Database\\ConnectionInterface'); $this->app->singleton('Illuminate\\Database\\ConnectionResolverInterface', function () { $resolver = new ConnectionResolver(['flarum' => $this->app->make('flarum.db')]); $resolver->setDefaultConnection('flarum'); return $resolver; }); $this->app->alias('Illuminate\\Database\\ConnectionResolverInterface', 'db'); if (Core::isInstalled()) { $this->app->booting(function () { $resolver = $this->app->make('Illuminate\\Database\\ConnectionResolverInterface'); Model::setConnectionResolver($resolver); Model::setEventDispatcher($this->app->make('events')); }); } $this->app->singleton('Flarum\\Migrations\\MigrationRepositoryInterface', function ($app) { return new DatabaseMigrationRepository($app['db'], 'migrations'); }); }
/** * Register the service provider. * * @return void */ public function register() { // Extensions will not be registered if Flarum is not installed yet if (!Core::isInstalled()) { return; } $extensions = json_decode(Core::config('extensions_enabled'), true); $providers = []; foreach ($extensions as $extension) { if (file_exists($file = base_path() . '/extensions/' . $extension . '/bootstrap.php')) { $providers[$extension] = (require $file); } } // @todo store $providers somewhere so that extensions can talk to each other }
* * (c) Toby Zerner <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Flarum\Core; use Flarum\Forum\Middleware\HandleErrors; use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware; use Zend\Diactoros\Server; use Zend\Stratigility\MiddlewarePipe; $app = (require __DIR__ . '/flarum/bootstrap.php'); // If Flarum's configuration exists, then we can assume that installation has // been completed. We will set up a middleware pipe to route the request through // to one of the main forum actions. if (Core::isInstalled()) { $app->register('Flarum\\Forum\\ForumServiceProvider'); $flarum = new MiddlewarePipe(); $flarum->pipe($app->make('Flarum\\Forum\\Middleware\\LoginWithCookie')); $flarum->pipe($app->make('Flarum\\Api\\Middleware\\ReadJsonParameters')); $basePath = parse_url(Core::url(), PHP_URL_PATH); $router = $app->make('Flarum\\Http\\RouterMiddleware', ['routes' => $app->make('flarum.forum.routes')]); $flarum->pipe($basePath, $router); if (Core::inDebugMode()) { $flarum->pipe(new WhoopsMiddleware()); } else { $flarum->pipe(new HandleErrors(base_path('error'))); } } else { $app->register('Flarum\\Install\\InstallServiceProvider'); $flarum = new MiddlewarePipe();