Fixing boot up process see #7124

1.10.x
Julio Montoya 11 years ago
parent 07c5cda136
commit d14d91abaf
  1. 2
      config/configuration.dist.php
  2. 2
      main/inc/lib/api.lib.php
  3. 32
      main/install/index.php
  4. 2
      main/install/install.lib.php
  5. 4
      src/ChamiloLMS/Command/Template/AsseticDumpCommand.php
  6. 61
      src/ChamiloLMS/Framework/Application.php
  7. 6
      src/ChamiloLMS/Resources/config/prod.php
  8. 54
      src/ChamiloLMS/app.php
  9. 21
      src/ChamiloLMS/paths.php
  10. 2
      src/ChamiloLMS/services.php

@ -54,7 +54,7 @@ $_configuration['main_database'] = '{DATABASE_MAIN}';
//$_configuration['path.courses'] = null;
// Path to the logs folder, example /var/www/chamilo/logs
//$_configuration['path.log'] = null;
//$_configuration['path.logs'] = null;
/**
*

@ -658,7 +658,7 @@ function api_get_path($path_type, $path = null) {
// Update data path to get it from config file if defined
$paths[SYS_DATA_PATH] = $app['path.data'];
$paths[SYS_LOG_PATH] = $app['path.log'];
$paths[SYS_LOG_PATH] = $app['path.logs'];
$paths[SYS_CONFIG_PATH] = $app['path.config'];
$paths[SYS_COURSE_PATH] = $app['path.courses'];

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Chamilo installation
* This script could be loaded via browser using the URL: main/install/index.php
@ -20,19 +21,25 @@ set_time_limit(0);
use Symfony\Component\Console\Output\Output;
use Symfony\Component\HttpFoundation\Request;
use ChamiloLMS\Component\Console\Output\BufferedOutput;
use ChamiloLMS\Framework\Application;
use Chash\Command\Installation\InstallCommand;
use Chash\Command\Installation\UpgradeCommand;
$app = new Silex\Application();
$app = new Application();
// Setting paths
$app['root_sys'] = dirname(dirname(__DIR__)).'/';
$app['sys_root'] = $app['root_sys'];
$app['sys_data_path'] = isset($_configuration['sys_data_path']) ? $_configuration['sys_data_path'] : $app['root_sys'].'data/';
$app['sys_config_path'] = isset($_configuration['sys_config_path']) ? $_configuration['sys_config_path'] : $app['root_sys'].'config/';
$app['sys_course_path'] = isset($_configuration['sys_course_path']) ? $_configuration['sys_course_path'] : $app['sys_data_path'].'/course/';
$app['sys_log_path'] = isset($_configuration['sys_log_path']) ? $_configuration['sys_log_path'] : $app['root_sys'].'logs/';
$app['sys_temp_path'] = isset($_configuration['sys_temp_path']) ? $_configuration['sys_temp_path'] : $app['sys_data_path'].'temp/';
$app['path.base'] = dirname(dirname(__DIR__)).'/';
$app['path.app'] = $app['path.base'].'src/ChamiloLMS/';
$app['path.config'] = $app['path.base'].'config/';
$app->bindInstallPaths(require $app['path.app'].'paths.php');
$app->readConfigurationFiles();
$app['path.data'] = isset($_configuration['path.data']) ? $_configuration['path.data'] : $app['path.data'];
$app['path.courses'] = isset($_configuration['path.courses']) ? $_configuration['path.courses'] : $app['path.courses'];
$app['path.logs'] = isset($_configuration['path.logs']) ? $_configuration['path.logs'] : $app['path.logs'];
$app['path.temp'] = isset($_configuration['path.temp']) ? $_configuration['path.temp'] : $app['path.temp'];
// Registering services
$app['debug'] = true;
@ -124,10 +131,7 @@ foreach ($helpers as $name => $helper) {
}
$blockInstallation = function () use ($app) {
if (file_exists($app['root_sys'].'config/configuration.php') ||
file_exists($app['root_sys'].'config/configuration.yml')
) {
if (file_exists($app['path.config'].'configuration.php')) {
return $app->abort(500, "A Chamilo installation was found. You can't reinstall.");
}
@ -485,13 +489,13 @@ $app->get('/finish', function () use ($app) {
$output = $app['session']->get('output');
$message = $app['translator']->trans(
'To protect your site, make the whole %s directory read-only (chmod 0555 on Unix/Linux)',
array('%s' => $app['root_sys'].'config')
array('%s' => $app['path.config'])
);
$app['session']->getFlashBag()->add('warning', $message);
$message = $app['translator']->trans(
'Delete the %s directory.',
array('%s' => $app['root_sys'].'install')
array('%s' => $app['path.base'].'install')
);
$app['session']->getFlashBag()->add('warning', $message);

@ -302,7 +302,7 @@ function drawPermissionsSettings($app)
$html .= '<div class="RequirementContent">';
$course_attempt_name = '__XxTestxX__';
$course_dir = $app['sys_course_path'].$course_attempt_name;
$course_dir = $app['path.courses'].$course_attempt_name;
// Just in case.
if (is_file($course_dir.'/test.txt')) {

@ -68,7 +68,7 @@ class AsseticDumpCommand extends Command
}
foreach ($themes as $theme) {
if (is_dir($app['root_sys'].'main/css/'.$theme) && file_exists($app['root_sys'].'main/css/'.$theme.'/default.css')) {
if (is_dir($app['path.base'].'main/css/'.$theme) && file_exists($app['path.base'].'main/css/'.$theme.'/default.css')) {
$output->writeln("<info>Dumping theme: $theme</info>");
/** @var \SilexAssetic\Assetic\Dumper $dumper */
@ -77,7 +77,7 @@ class AsseticDumpCommand extends Command
$app['assetic.output.path_to_css'] = 'css/'.$theme.'/style.css';
$params = array(
$app['root_sys'].'main/css/'.$theme => $app['assetic.input.path_to_assets'].'/css/'.$theme
$app['path.base'].'main/css/'.$theme => $app['assetic.input.path_to_assets'].'/css/'.$theme
);
$app['chamilo.filesystem']->copyFolders($params, $output);

@ -3,7 +3,7 @@
namespace ChamiloLMS\Framework;
use Zend\Config;
use Zend\Config\Config;
/**
* Class Application
@ -41,6 +41,9 @@ class Application extends \Silex\Application
return $this->configurationArray;
}
/**
* @return Config
*/
public function getConfiguration()
{
return $this->configuration;
@ -64,7 +67,7 @@ class Application extends \Silex\Application
$this->configuration = $this->getConfigurationArrayFromFile();
if (!empty($this->configuration)) {
$config = new \Zend\Config\Config($this->configuration, true);
$config = new Config($this->configuration, true);
$this->installed = true;
/** Overwriting paths */
@ -72,7 +75,7 @@ class Application extends \Silex\Application
$this['path.data'] = empty($config->get('path.data')) ? $this['path.data'] : $config->get('path.data');
$this['path.course'] = empty($config->get('path.courses')) ? $this['path.courses'] : $config->get('path.courses');
$this['path.temp'] = empty($config->get('path.temp')) ? $this['path.temp'] : $config->get('path.temp');
$this['path.log'] = empty($config->get('path.log')) ? $this['path.log'] : $config->get('path.log');
$this['path.logs'] = empty($config->get('path.logs')) ? $this['path.logs'] : $config->get('path.logs');
$configPath = $this['path.config'];
@ -112,4 +115,56 @@ class Application extends \Silex\Application
$this->configuration = $config;
}
}
public function setupDoctrineExtensions()
{
if (isset($this->getConfiguration()->main_database) && isset($this['db.event_manager'])) {
// @todo improvement do not create every time this objects
$sortableGroup = new \Gedmo\Mapping\Annotation\SortableGroup(array());
$sortablePosition = new \Gedmo\Mapping\Annotation\SortablePosition(array());
$tree = new \Gedmo\Mapping\Annotation\Tree(array());
$tree = new \Gedmo\Mapping\Annotation\TreeParent(array());
$tree = new \Gedmo\Mapping\Annotation\TreeLeft(array());
$tree = new \Gedmo\Mapping\Annotation\TreeRight(array());
$tree = new \Gedmo\Mapping\Annotation\TreeRoot(array());
$tree = new \Gedmo\Mapping\Annotation\TreeLevel(array());
$tree = new \Gedmo\Mapping\Annotation\Versioned(array());
$tree = new \Gedmo\Mapping\Annotation\Loggable(array());
$tree = new \Gedmo\Loggable\Entity\LogEntry();
// Setting Doctrine2 extensions
$timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
// $app['db.event_manager']->addEventSubscriber($timestampableListener);
$this['dbs.event_manager']['db_read']->addEventSubscriber($timestampableListener);
$this['dbs.event_manager']['db_write']->addEventSubscriber($timestampableListener);
$sluggableListener = new \Gedmo\Sluggable\SluggableListener();
// $this['db.event_manager']->addEventSubscriber($sluggableListener);
$this['dbs.event_manager']['db_read']->addEventSubscriber($sluggableListener);
$this['dbs.event_manager']['db_write']->addEventSubscriber($sluggableListener);
$sortableListener = new \Gedmo\Sortable\SortableListener();
// $this['db.event_manager']->addEventSubscriber($sortableListener);
$this['dbs.event_manager']['db_read']->addEventSubscriber($sortableListener);
$this['dbs.event_manager']['db_write']->addEventSubscriber($sortableListener);
$treeListener = new \Gedmo\Tree\TreeListener();
//$treeListener->setAnnotationReader($cachedAnnotationReader);
// $this['db.event_manager']->addEventSubscriber($treeListener);
$this['dbs.event_manager']['db_read']->addEventSubscriber($treeListener);
$this['dbs.event_manager']['db_write']->addEventSubscriber($treeListener);
$loggableListener = new \Gedmo\Loggable\LoggableListener();
if (PHP_SAPI != 'cli') {
//$userInfo = api_get_user_info();
if (isset($userInfo) && !empty($userInfo['username'])) {
//$loggableListener->setUsername($userInfo['username']);
}
}
$this['dbs.event_manager']['db_read']->addEventSubscriber($loggableListener);
$this['dbs.event_manager']['db_write']->addEventSubscriber($loggableListener);
}
}
}

@ -13,7 +13,7 @@ $app['temp.paths'] = new stdClass();
$app['temp.paths']->folders[] = $app['path.data'];
// Monolog.
$app['temp.paths']->folders[] = $app['path.log'];
$app['temp.paths']->folders[] = $app['path.logs'];
// Twig cache.
$app['temp.paths']->folders[] = $app['twig.cache.path'] = $app['temp.path'].'twig';
@ -101,13 +101,13 @@ if ($app['assetic.enabled']) {
$app['temp.paths']->folders[] = $app['assetic.path_to_web'].'/js';
$app['temp.paths']->copyFolders = array(
$app['root_sys'].'main/css/'.$app['app.theme'] => $app['assetic.path_to_web'].'/css/'.$app['app.theme']
$app['path.base'].'main/css/'.$app['app.theme'] => $app['assetic.path_to_web'].'/css/'.$app['app.theme']
);
//}
}
// Monolog log file
$app['chamilo.log'] = $app['path.log'].'chamilo.log';
$app['chamilo.log'] = $app['path.logs'].'chamilo.log';
// If the chamilo.lig is not writable try to delete it
if (is_file($app['chamilo.log']) && !is_writable($app['chamilo.log'])) {

@ -202,7 +202,7 @@ $app->error(
// Checking if we have a valid language. If not we set it to the platform language.
$cidReset = null;
require_once $basePath . 'src/ChamiloLMS/filters.php';
require_once $app['path.app'].'filters.php';
// The global variable $charset has been defined in a language file too (trad4all.inc.php), this is legacy situation.
// So, we have to reassign this variable again in order to keep its value right.
@ -216,57 +216,9 @@ $text_dir = api_get_text_direction();
$app['is_admin'] = false;
/** Including routes */
require_once 'routes.php';
require_once $app['path.app'].'routes.php';
// Setting doctrine2 extensions
if (isset($app->getConfiguration()->main_database) && isset($app['db.event_manager'])) {
// @todo improvement do not create every time this objects
$sortableGroup = new Gedmo\Mapping\Annotation\SortableGroup(array());
$sortablePosition = new Gedmo\Mapping\Annotation\SortablePosition(array());
$tree = new Gedmo\Mapping\Annotation\Tree(array());
$tree = new Gedmo\Mapping\Annotation\TreeParent(array());
$tree = new Gedmo\Mapping\Annotation\TreeLeft(array());
$tree = new Gedmo\Mapping\Annotation\TreeRight(array());
$tree = new Gedmo\Mapping\Annotation\TreeRoot(array());
$tree = new Gedmo\Mapping\Annotation\TreeLevel(array());
$tree = new Gedmo\Mapping\Annotation\Versioned(array());
$tree = new Gedmo\Mapping\Annotation\Loggable(array());
$tree = new Gedmo\Loggable\Entity\LogEntry();
// Setting Doctrine2 extensions
$timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
// $app['db.event_manager']->addEventSubscriber($timestampableListener);
$app['dbs.event_manager']['db_read']->addEventSubscriber($timestampableListener);
$app['dbs.event_manager']['db_write']->addEventSubscriber($timestampableListener);
$sluggableListener = new \Gedmo\Sluggable\SluggableListener();
// $app['db.event_manager']->addEventSubscriber($sluggableListener);
$app['dbs.event_manager']['db_read']->addEventSubscriber($sluggableListener);
$app['dbs.event_manager']['db_write']->addEventSubscriber($sluggableListener);
$sortableListener = new Gedmo\Sortable\SortableListener();
// $app['db.event_manager']->addEventSubscriber($sortableListener);
$app['dbs.event_manager']['db_read']->addEventSubscriber($sortableListener);
$app['dbs.event_manager']['db_write']->addEventSubscriber($sortableListener);
$treeListener = new \Gedmo\Tree\TreeListener();
//$treeListener->setAnnotationReader($cachedAnnotationReader);
// $app['db.event_manager']->addEventSubscriber($treeListener);
$app['dbs.event_manager']['db_read']->addEventSubscriber($treeListener);
$app['dbs.event_manager']['db_write']->addEventSubscriber($treeListener);
$loggableListener = new \Gedmo\Loggable\LoggableListener();
if (PHP_SAPI != 'cli') {
//$userInfo = api_get_user_info();
if (isset($userInfo) && !empty($userInfo['username'])) {
//$loggableListener->setUsername($userInfo['username']);
}
}
$app['dbs.event_manager']['db_read']->addEventSubscriber($loggableListener);
$app['dbs.event_manager']['db_write']->addEventSubscriber($loggableListener);
}
$app->setupDoctrineExtensions();
return $app;

@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
return array(
/* Base path */
'base' => __DIR__.'/../../',
/* Application path */
'app' => __DIR__.'/../../src/ChamiloLMS',
/* Config */
'config' => __DIR__.'/../../config',
// Can be overwritten in configuration.php
/* data */
'data' => __DIR__.'/../../data',
/* temp */
'temp' => __DIR__.'/../../data/temp',
/* courses */
'courses' => __DIR__.'/../../data/courses',
/* Log */
'logs' => __DIR__.'/../../logs',
);

@ -660,7 +660,7 @@ class ChamiloServiceProvider implements ServiceProviderInterface
'sys_data_path' => $app['path.data'],
'sys_config_path' => $app['path.config'],
'path.temp' => $app['path.temp'],
'sys_log_path' => $app['path.log']
'sys_log_path' => $app['path.logs']
);
});

Loading…
Cancel
Save