framework/src/Update/UpdateServiceProvider.php
Toby Zerner 1242fa79af Implement proper update process
If the version in the settings table mismatches the code version, then we return a 503 error for all requests coming through index.php and api.php, while admin.php serves up a form prompting for the database password which will run outstanding migrations.
2015-10-19 15:09:54 +10:30

58 lines
1.3 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Update;
use Flarum\Http\GenerateRouteHandlerTrait;
use Flarum\Http\RouteCollection;
use Flarum\Foundation\AbstractServiceProvider;
use Psr\Http\Message\ServerRequestInterface;
class UpdateServiceProvider extends AbstractServiceProvider
{
use GenerateRouteHandlerTrait;
/**
* {@inheritdoc}
*/
public function register()
{
$this->app->singleton('flarum.update.routes', function () {
return $this->getRoutes();
});
$this->loadViewsFrom(__DIR__.'/../../views/install', 'flarum.update');
}
/**
* @return RouteCollection
*/
protected function getRoutes()
{
$routes = new RouteCollection;
$toController = $this->getHandlerGenerator($this->app);
$routes->get(
'/',
'index',
$toController('Flarum\Update\Controller\IndexController')
);
$routes->post(
'/',
'update',
$toController('Flarum\Update\Controller\UpdateController')
);
return $routes;
}
}