Files
Phraseanet/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php
2012-10-04 15:31:36 +02:00

71 lines
2.4 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Setup;
use Silex\Application;
use Silex\ControllerProviderInterface;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Upgrader implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->get('/', function() use ($app) {
require_once __DIR__ . '/../../../../bootstrap.php';
$upgrade_status = \Setup_Upgrade::get_status();
return $app['twig']->render(
'/setup/upgrader.html.twig'
, array(
'locale' => \Session_Handler::get_locale()
, 'upgrade_status' => $upgrade_status
, 'available_locales' => $app['phraseanet.core']::getAvailableLanguages()
, 'bad_users' => \User_Adapter::get_wrong_email_users($app['phraseanet.appbox'])
, 'version_number' => $app['phraseanet.core']['Version']->getNumber()
, 'version_name' => $app['phraseanet.core']['Version']->getName()
)
);
});
$controllers->get('/status/', function(Application $app) {
require_once __DIR__ . '/../../../../bootstrap.php';
return $app->json(\Setup_Upgrade::get_status());
});
$controllers->post('/execute/', function(Application $app) {
require_once __DIR__ . '/../../../../bootstrap.php';
set_time_limit(0);
session_write_close();
ignore_user_abort(true);
$appbox = $app['phraseanet.appbox'];
$upgrader = new \Setup_Upgrade($appbox);
$appbox->forceUpgrade($upgrader, $app['phraseanet.core']['CacheService'], $app['phraseanet.core']['EM'], $app['filesystem']);
/**
* @todo Show recomandation instead of redirect
*/
return $app->redirect('/');
});
return $controllers;
}
}