mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
Update setup/upgrade controllers
This commit is contained in:
@@ -30,8 +30,17 @@ class Installer implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->get('/', function(Application $app, Request $request) {
|
$controllers->get('/', $this->call('rootInstaller'));
|
||||||
|
|
||||||
|
$controllers->get('/step2/', $this->call('getInstallForm'));
|
||||||
|
|
||||||
|
$controllers->post('/install/', $this->call('doInstall'));
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rootInstaller(Application $app, Request $request)
|
||||||
|
{
|
||||||
$php_constraint = \setup::check_php_version();
|
$php_constraint = \setup::check_php_version();
|
||||||
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
||||||
$extension_constraints = \setup::check_php_extension();
|
$extension_constraints = \setup::check_php_extension();
|
||||||
@@ -64,23 +73,24 @@ class Installer implements ControllerProviderInterface
|
|||||||
return $app->redirect('/setup/installer/step2/');
|
return $app->redirect('/setup/installer/step2/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
$app['twig.loader.filesystem']->setPaths(array(
|
||||||
$loader = new \Twig_Loader_Filesystem($ld_path);
|
__DIR__ . '/../../../../../templates/web'
|
||||||
$twig = new \Twig_Environment($loader);
|
));
|
||||||
|
|
||||||
return $twig->render(
|
return $app['twig']->render(
|
||||||
'/setup/index.html.twig'
|
'/setup/index.html.twig'
|
||||||
, array_merge($constraints_coll, array(
|
, array_merge($constraints_coll, array(
|
||||||
'locale' => \Session_Handler::get_locale()
|
'locale' => \Session_Handler::get_locale()
|
||||||
, 'available_locales' => $app['phraseanet.core']::getAvailableLanguages()
|
, 'available_locales' => $app->getAvailableLanguages()
|
||||||
, 'version_number' => $app['phraseanet.core']['Version']->getNumber()
|
, 'version_number' => $app['phraseanet.version']->getNumber()
|
||||||
, 'version_name' => $app['phraseanet.core']['Version']->getName()
|
, 'version_name' => $app['phraseanet.version']->getName()
|
||||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
$controllers->get('/step2/', function(Application $app, Request $request) {
|
public function getInstallForm(Application $app, Request $request)
|
||||||
|
{
|
||||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
|
|
||||||
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
||||||
@@ -124,10 +134,10 @@ class Installer implements ControllerProviderInterface
|
|||||||
'/setup/step2.html.twig'
|
'/setup/step2.html.twig'
|
||||||
, array(
|
, array(
|
||||||
'locale' => \Session_Handler::get_locale()
|
'locale' => \Session_Handler::get_locale()
|
||||||
, 'available_locales' => $app['phraseanet.core']::getAvailableLanguages()
|
, 'available_locales' => $app->getAvailableLanguages()
|
||||||
, 'available_templates' => \appbox::list_databox_templates()
|
, 'available_templates' => \appbox::list_databox_templates()
|
||||||
, 'version_number' => $app['phraseanet.core']['Version']->getNumber()
|
, 'version_number' => $app['phraseanet.version']->getNumber()
|
||||||
, 'version_name' => $app['phraseanet.core']['Version']->getName()
|
, 'version_name' => $app['phraseanet.version']->getName()
|
||||||
, 'warnings' => $warnings
|
, 'warnings' => $warnings
|
||||||
, 'error' => $request->query->get('error')
|
, 'error' => $request->query->get('error')
|
||||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
@@ -135,9 +145,10 @@ class Installer implements ControllerProviderInterface
|
|||||||
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
$controllers->post('/install/', function(Application $app, Request $request) {
|
public function doInstall(Application $app, Request $request)
|
||||||
|
{
|
||||||
set_time_limit(360);
|
set_time_limit(360);
|
||||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
|
|
||||||
@@ -172,7 +183,7 @@ class Installer implements ControllerProviderInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$appbox = \appbox::create($app['phraseanet.core'], $setupRegistry, $conn, $appbox_name, true);
|
$appbox = \appbox::create($app, $setupRegistry, $conn, $appbox_name, $app['phraseanet.appbox'], true);
|
||||||
|
|
||||||
$configuration = Configuration::build();
|
$configuration = Configuration::build();
|
||||||
|
|
||||||
@@ -180,10 +191,7 @@ class Installer implements ControllerProviderInterface
|
|||||||
$serviceName = $configuration->getOrm();
|
$serviceName = $configuration->getOrm();
|
||||||
$confService = $configuration->getService($serviceName);
|
$confService = $configuration->getService($serviceName);
|
||||||
|
|
||||||
$ormService = ServiceBuilder::create(
|
$ormService = ServiceBuilder::create($app, $confService);
|
||||||
$app['phraseanet.core']
|
|
||||||
, $confService
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($ormService->getType() === 'doctrine') {
|
if ($ormService->getType() === 'doctrine') {
|
||||||
/* @var $em \Doctrine\ORM\EntityManager */
|
/* @var $em \Doctrine\ORM\EntityManager */
|
||||||
@@ -202,10 +210,10 @@ class Installer implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$registry = \registry::get_instance();
|
$registry = $app['phraseanet.registry'];
|
||||||
\setup::create_global_values($registry);
|
\setup::create_global_values($app);
|
||||||
|
|
||||||
$appbox->set_registry($registry);
|
// $appbox->set_registry($registry);
|
||||||
|
|
||||||
$registry->set('GV_base_datapath_noweb', \p4string::addEndSlash($request->request->get('datapath_noweb')), \registry::TYPE_STRING);
|
$registry->set('GV_base_datapath_noweb', \p4string::addEndSlash($request->request->get('datapath_noweb')), \registry::TYPE_STRING);
|
||||||
$registry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
$registry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
||||||
@@ -220,9 +228,9 @@ class Installer implements ControllerProviderInterface
|
|||||||
$registry->set('GV_mp4box', $request->request->get('binary_MP4Box'), \registry::TYPE_STRING);
|
$registry->set('GV_mp4box', $request->request->get('binary_MP4Box'), \registry::TYPE_STRING);
|
||||||
$registry->set('GV_pdftotext', $request->request->get('binary_xpdf'), \registry::TYPE_STRING);
|
$registry->set('GV_pdftotext', $request->request->get('binary_xpdf'), \registry::TYPE_STRING);
|
||||||
|
|
||||||
$user = \User_Adapter::create($appbox, $request->request->get('email'), $request->request->get('password'), $request->request->get('email'), true);
|
$user = \User_Adapter::create($app, $request->request->get('email'), $request->request->get('password'), $request->request->get('email'), true);
|
||||||
|
|
||||||
\phrasea::start($app['phraseanet.core']);
|
\phrasea::start($app['phraseanet.configuration']);
|
||||||
|
|
||||||
$auth = new \Session_Authentication_None($user);
|
$auth = new \Session_Authentication_None($user);
|
||||||
|
|
||||||
@@ -230,7 +238,7 @@ class Installer implements ControllerProviderInterface
|
|||||||
|
|
||||||
if ($databox_name && !\p4string::hasAccent($databox_name)) {
|
if ($databox_name && !\p4string::hasAccent($databox_name)) {
|
||||||
$template = new \SplFileInfo(__DIR__ . '/../../../../conf.d/data_templates/' . $request->request->get('db_template') . '.xml');
|
$template = new \SplFileInfo(__DIR__ . '/../../../../conf.d/data_templates/' . $request->request->get('db_template') . '.xml');
|
||||||
$databox = \databox::create($appbox, $connbas, $template, $registry);
|
$databox = \databox::create($app, $connbas, $template, $registry);
|
||||||
$user->ACL()
|
$user->ACL()
|
||||||
->give_access_to_sbas(array($databox->get_sbas_id()))
|
->give_access_to_sbas(array($databox->get_sbas_id()))
|
||||||
->update_rights_to_sbas(
|
->update_rights_to_sbas(
|
||||||
@@ -240,7 +248,7 @@ class Installer implements ControllerProviderInterface
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$a = \collection::create($databox, $appbox, 'test', $user);
|
$a = \collection::create($app, $databox, $appbox, 'test', $user);
|
||||||
|
|
||||||
$user->ACL()->give_access_to_base(array($a->get_base_id()));
|
$user->ACL()->give_access_to_base(array($a->get_base_id()));
|
||||||
$user->ACL()->update_rights_to_base($a->get_base_id(), array(
|
$user->ACL()->update_rights_to_base($a->get_base_id(), array(
|
||||||
@@ -296,8 +304,16 @@ class Installer implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage()));
|
return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage()));
|
||||||
});
|
}
|
||||||
|
|
||||||
return $controllers;
|
/**
|
||||||
|
* Prefix the method to call with the controller class name
|
||||||
|
*
|
||||||
|
* @param string $method The method to call
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function call($method)
|
||||||
|
{
|
||||||
|
return sprintf('%s::%s', __CLASS__, $method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,10 +35,10 @@ class Upgrader implements ControllerProviderInterface
|
|||||||
, array(
|
, array(
|
||||||
'locale' => \Session_Handler::get_locale()
|
'locale' => \Session_Handler::get_locale()
|
||||||
, 'upgrade_status' => $upgrade_status
|
, 'upgrade_status' => $upgrade_status
|
||||||
, 'available_locales' => $app['phraseanet.core']::getAvailableLanguages()
|
, 'available_locales' => $app->getAvailableLanguages()
|
||||||
, 'bad_users' => \User_Adapter::get_wrong_email_users($app['phraseanet.appbox'])
|
, 'bad_users' => \User_Adapter::get_wrong_email_users($app)
|
||||||
, 'version_number' => $app['phraseanet.core']['Version']->getNumber()
|
, 'version_number' => $app['phraseanet.version']->getNumber()
|
||||||
, 'version_name' => $app['phraseanet.core']['Version']->getName()
|
, 'version_name' => $app['phraseanet.version']->getName()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -56,8 +56,8 @@ class Upgrader implements ControllerProviderInterface
|
|||||||
ignore_user_abort(true);
|
ignore_user_abort(true);
|
||||||
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$upgrader = new \Setup_Upgrade($appbox);
|
$upgrader = new \Setup_Upgrade($app);
|
||||||
$appbox->forceUpgrade($upgrader, $app['phraseanet.core']['CacheService'], $app['phraseanet.core']['EM'], $app['filesystem']);
|
$appbox->forceUpgrade($upgrader, $app);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Show recomandation instead of redirect
|
* @todo Show recomandation instead of redirect
|
||||||
|
@@ -7,7 +7,7 @@ use Alchemy\Phrasea\Controller\Setup as Controller;
|
|||||||
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||||
|
|
||||||
return call_user_func(function() {
|
return call_user_func(function() {
|
||||||
$app = new PhraseaApplication();
|
$app = new PhraseaApplication('test');
|
||||||
|
|
||||||
$app['install'] = true;
|
$app['install'] = true;
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ use Alchemy\Phrasea\Controller\Setup as Controller;
|
|||||||
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||||
|
|
||||||
return call_user_func(function() {
|
return call_user_func(function() {
|
||||||
$app = new PhraseaApplication();
|
$app = new PhraseaApplication('test');
|
||||||
|
|
||||||
$app['upgrade'] = true;
|
$app['upgrade'] = true;
|
||||||
|
|
||||||
|
@@ -4,28 +4,11 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
|
|||||||
|
|
||||||
class ControllerInstallerTest extends \PhraseanetWebTestCaseAbstract
|
class ControllerInstallerTest extends \PhraseanetWebTestCaseAbstract
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* As controllers use WebTestCase, it requires a client
|
|
||||||
*/
|
|
||||||
protected $client;
|
|
||||||
|
|
||||||
/**
|
protected static function loadApplication()
|
||||||
* The application loader
|
|
||||||
*/
|
|
||||||
public function createApplication()
|
|
||||||
{
|
{
|
||||||
$app = require __DIR__ . '/FakeSetupApplication.inc';
|
$environment = 'test';
|
||||||
|
return self::$application = require __DIR__ . '/FakeSetupApplication.inc';
|
||||||
$app['debug'] = true;
|
|
||||||
unset($app['exception_handler']);
|
|
||||||
|
|
||||||
return $app;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->client = $this->createClient();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -4,25 +4,11 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
|
|||||||
|
|
||||||
class ControllerUpgraderTest extends \PhraseanetWebTestCaseAbstract
|
class ControllerUpgraderTest extends \PhraseanetWebTestCaseAbstract
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* As controllers use WebTestCase, it requires a client
|
|
||||||
*/
|
|
||||||
protected $client;
|
|
||||||
|
|
||||||
public function createApplication()
|
protected static function loadApplication()
|
||||||
{
|
{
|
||||||
$app = require __DIR__ . '/FakeUpgradeApplication.inc';
|
$environment = 'test';
|
||||||
|
return self::$application = require __DIR__ . '/FakeUpgradeApplication.inc';
|
||||||
$app['debug'] = true;
|
|
||||||
unset($app['exception_handler']);
|
|
||||||
|
|
||||||
return $app;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->client = $this->createClient();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user