1
0
mirror of https://github.com/flarum/core.git synced 2025-10-14 00:15:51 +02:00
Files
php-flarum/src/Install/Controller/IndexController.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

61 lines
1.6 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\Install\Controller;
use Flarum\Install\Prerequisite\PrerequisiteInterface;
use Flarum\Http\Controller\AbstractHtmlController;
use Psr\Http\Message\ServerRequestInterface as Request;
use Illuminate\Contracts\View\Factory;
class IndexController extends AbstractHtmlController
{
/**
* @var Factory
*/
protected $view;
/**
* @var \Flarum\Install\Prerequisite\PrerequisiteInterface
*/
protected $prerequisite;
/**
* @param Factory $view
* @param PrerequisiteInterface $prerequisite
*/
public function __construct(Factory $view, PrerequisiteInterface $prerequisite)
{
$this->view = $view;
$this->prerequisite = $prerequisite;
}
/**
* @param Request $request
* @param array $routeParams
* @return \Psr\Http\Message\ResponseInterface
*/
public function render(Request $request, array $routeParams = [])
{
$view = $this->view->make('flarum.install::app')->with('title', 'Install Flarum');
$this->prerequisite->check();
$errors = $this->prerequisite->getErrors();
if (count($errors)) {
$view->with('content', $this->view->make('flarum.install::errors')->with('errors', $errors));
} else {
$view->with('content', $this->view->make('flarum.install::install'));
}
return $view;
}
}