1
0
mirror of https://github.com/flarum/core.git synced 2025-10-13 07:54:25 +02:00

Implement web installer

This commit is contained in:
Toby Zerner
2015-08-17 14:12:02 +09:30
parent 17dbeefabe
commit 1052aa55ea
10 changed files with 596 additions and 45 deletions

View File

@@ -0,0 +1,60 @@
<?php namespace Flarum\Install;
use Flarum\Http\RouteCollection;
use Flarum\Http\UrlGenerator;
use Flarum\Support\ServiceProvider;
use Psr\Http\Message\ServerRequestInterface;
class InstallServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->register('Flarum\Locale\LocaleServiceProvider');
}
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$root = __DIR__.'/../..';
$this->loadViewsFrom($root.'/views/install', 'flarum.install');
$this->routes();
}
protected function routes()
{
$this->app->instance('flarum.install.routes', $routes = new RouteCollection);
$routes->get(
'/',
'flarum.install.index',
$this->action('Flarum\Install\Actions\IndexAction')
);
$routes->post(
'/',
'flarum.install.install',
$this->action('Flarum\Install\Actions\InstallAction')
);
}
protected function action($class)
{
return function (ServerRequestInterface $httpRequest, $routeParams) use ($class) {
/** @var \Flarum\Support\Action $action */
$action = $this->app->make($class);
return $action->handle($httpRequest, $routeParams);
};
}
}