Fix installer/updater

This commit is contained in:
Toby Zerner 2016-05-27 14:53:22 +09:30
parent be08c32c96
commit 15adfc528f
2 changed files with 28 additions and 21 deletions

View File

@ -11,7 +11,7 @@
namespace Flarum\Install;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Http\GenerateRouteHandlerTrait;
use Flarum\Http\Handler\RouteHandlerFactory;
use Flarum\Http\RouteCollection;
use Flarum\Install\Prerequisite\Composite;
use Flarum\Install\Prerequisite\PhpExtensions;
@ -20,8 +20,6 @@ use Flarum\Install\Prerequisite\WritablePaths;
class InstallServiceProvider extends AbstractServiceProvider
{
use GenerateRouteHandlerTrait;
/**
* {@inheritdoc}
*/
@ -51,33 +49,37 @@ class InstallServiceProvider extends AbstractServiceProvider
);
$this->app->singleton('flarum.install.routes', function () {
return $this->getRoutes();
return new RouteCollection;
});
$this->loadViewsFrom(__DIR__.'/../../views/install', 'flarum.install');
}
/**
* @return RouteCollection
* {@inheritdoc}
*/
protected function getRoutes()
public function boot()
{
$routes = new RouteCollection;
$this->populateRoutes($this->app->make('flarum.install.routes'));
}
$toController = $this->getHandlerGenerator($this->app);
/**
* @param RouteCollection $routes
*/
protected function populateRoutes(RouteCollection $routes)
{
$route = $this->app->make(RouteHandlerFactory::class);
$routes->get(
'/',
'index',
$toController('Flarum\Install\Controller\IndexController')
$route->toController(Controller\IndexController::class)
);
$routes->post(
'/',
'install',
$toController('Flarum\Install\Controller\InstallController')
$route->toController(Controller\InstallController::class)
);
return $routes;
}
}

View File

@ -12,6 +12,7 @@ namespace Flarum\Update;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Http\GenerateRouteHandlerTrait;
use Flarum\Http\Handler\RouteHandlerFactory;
use Flarum\Http\RouteCollection;
class UpdateServiceProvider extends AbstractServiceProvider
@ -24,33 +25,37 @@ class UpdateServiceProvider extends AbstractServiceProvider
public function register()
{
$this->app->singleton('flarum.update.routes', function () {
return $this->getRoutes();
return new RouteCollection;
});
$this->loadViewsFrom(__DIR__.'/../../views/install', 'flarum.update');
}
/**
* @return RouteCollection
* {@inheritdoc}
*/
protected function getRoutes()
public function boot()
{
$routes = new RouteCollection;
$this->populateRoutes($this->app->make('flarum.install.routes'));
}
$toController = $this->getHandlerGenerator($this->app);
/**
* @param RouteCollection $routes
*/
protected function populateRoutes(RouteCollection $routes)
{
$route = $this->app->make(RouteHandlerFactory::class);
$routes->get(
'/',
'index',
$toController('Flarum\Update\Controller\IndexController')
$route->toController(Controller\IndexController::class)
);
$routes->post(
'/',
'update',
$toController('Flarum\Update\Controller\UpdateController')
$route->toController(Controller\UpdateController::class)
);
return $routes;
}
}