Minor - WIP Database created and schema created using symfony #2320

pull/2487/head
jmontoyaa 8 years ago
parent 53af2f7b7d
commit 2f45169ece
  1. 5
      composer.json
  2. 22
      config/packages/fos_rest.yaml
  3. 2
      config/packages/knp_menu.yaml
  4. 9
      config/packages/mopa_bootstrap.yaml
  5. 6
      config/packages/sonata_page.yaml
  6. 2
      config/packages/twig.yaml
  7. 24
      main/inc/global.inc.php
  8. 21
      main/inc/lib/api.lib.php
  9. 1
      main/inc/lib/chamilo_session.class.php
  10. 17
      main/inc/lib/database.lib.php
  11. 6
      main/inc/lib/internationalization.lib.php
  12. 30
      main/inc/lib/usermanager.lib.php
  13. 56
      main/install/index.php
  14. 68
      main/install/install.lib.php
  15. 1
      public/legacy.php
  16. 1
      src/CoreBundle/EventListener/LegacyListener.php
  17. 77
      src/CoreBundle/Framework/Container.php
  18. 22
      src/CoreBundle/Resources/config/services.yml
  19. 5
      src/Kernel.php
  20. 1
      src/UserBundle/Security/Encoder.php
  21. 1
      templates/bundles/TwigBundle/Exception/error.html.twig
  22. 1
      templates/bundles/TwigBundle/Exception/exception_full.html.twig
  23. 5
      translations/installation.en.po

@ -128,7 +128,7 @@
"knplabs/knp-components": "^1.3",
"michelf/php-markdown": "~1.8",
"mopa/bootstrap-bundle": "~3.0",
"mopa/bootstrap-bundle": "~3.2",
"sabre/vobject": "~3.1",
"emojione/emojione": "1.3.0",
@ -165,7 +165,8 @@
"lunetics/locale-bundle": "2.5.*",
"hwi/oauth-bundle": "^0.6.0",
"php-http/guzzle6-adapter": "^1.1",
"php-http/httplug-bundle": "^1.8"
"php-http/httplug-bundle": "^1.8",
"knplabs/knp-menu-bundle": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.7",

@ -1,12 +1,12 @@
#fos_rest:
# param_fetcher_listener: true
# body_listener: true
# format_listener: true
# view:
# view_response_listener: force
# body_converter:
# enabled: false
# validate: true
fos_rest:
param_fetcher_listener: true
body_listener: true
format_listener: true
view:
view_response_listener: force
body_converter:
enabled: false
validate: true
# exception:
# messages:
# 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException': true
# enabled: true
# exception_controller: 'Chamilo\ThemeBundle\Controller\ExceptionController::showAction'

@ -0,0 +1,2 @@
knp_menu:
default_renderer: twig

@ -18,3 +18,12 @@ mopa_bootstrap:
icon: plus-sign
attr:
class: btn btn-primary
icons:
icon_set: fontawesome4
shortcut: icon

@ -150,9 +150,9 @@ sonata_page:
- '%sonata_page.varnish.command%' # you need to adapt this line to work with your configuration
ssi:
token: add an unique token here # default is a random value
catch_exceptions:
not_found: [404] # render 404 page with "not_found" key (name generated: _page_internal_error_{key})
fatal: [500] # so you can use the same page for different http errors or specify specific page for each error
# catch_exceptions:
# not_found: [404] # render 404 page with "not_found" key (name generated: _page_internal_error_{key})
# fatal: [500] # so you can use the same page for different http errors or specify specific page for each error
# Enable Doctrine to map the provided entities
doctrine:
orm:

@ -1,5 +1,5 @@
twig:
paths: ['%kernel.project_dir%/templates']
paths: ['%kernel.project_dir%/templates', '%kernel.project_dir%/main/template/']
debug: '%kernel.debug%'
exception_controller: 'Chamilo\ThemeBundle\Controller\ExceptionController::showAction'
globals:

@ -38,8 +38,12 @@ $kernel = new Chamilo\Kernel($env, true);
// Include the main Chamilo platform configuration file.
$alreadyInstalled = false;
// Boot Symfony container
$kernel->boot();
require_once __DIR__.'/../../public/legacy.php';
$request = Sonata\PageBundle\Request\RequestFactory::createFromGlobals(
'host_with_path_by_locale'
);
$response = $kernel->handle($request);
if ($kernel->isInstalled()) {
require_once $kernel->getConfigurationFile();
@ -90,13 +94,21 @@ require_once $libraryPath.'fileDisplay.lib.php';
require_once $libraryPath.'course_category.lib.php';
$container = $kernel->getContainer();
$doctrine = $container->get('doctrine');
// Connect Chamilo with the Symfony container
$database = new \Database();
$database->setManager($doctrine->getManager());
$database->setConnection($doctrine->getConnection());
Container::setContainer($container);
Container::setLegacyServices($container);
$router = $container->get('router');
$context = $container->get('router.request_context');
$append = $kernel->getUrlAppend();
$baseUrl = '..';
if (!empty($append)) {
$baseUrl = $append;
}
$context->setBaseUrl($baseUrl);
$router->setContext($context);
//$container->setParameter('router', $router);
\CourseManager::setCourseManager(
$container->get('chamilo_core.entity.manager.course_manager')

@ -701,6 +701,8 @@ function api_get_path($path = '', $configuration = [])
$course_folder = 'courses/';
static $root_web = '';
//var_dump(Container::getRouter()->generate('legacy_index'));exit;
$root_sys = Container::getRootDir();
// If no $root_web has been set so far *and* no custom config has been passed to the function
@ -2620,6 +2622,18 @@ function api_get_setting($variable)
return $value;
}
/**
* @param string $variable
* @param string $option
* @return bool
*/
function api_get_setting_in_list($variable, $option)
{
$value = api_get_setting($variable);
return in_array($option, $value);
}
/**
* @param string $plugin
* @param string $variable
@ -4555,11 +4569,11 @@ function api_get_languages()
$sql = "SELECT * FROM $tbl_language WHERE available='1'
ORDER BY original_name ASC";
$result = Database::query($sql);
$language_list = [];
$languages = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
$language_list[$row['isocode']] = $row['original_name'];
$languages[$row['isocode']] = $row['original_name'];
}
return $language_list;
return $languages;
}
/**
@ -7030,7 +7044,6 @@ function api_check_archive_dir()
function api_get_locked_settings()
{
return [
'server_type',
'permanently_remove_deleted_files',
'account_valid_duration',
'service_ppt2lp',

@ -16,6 +16,7 @@ class ChamiloSession implements \ArrayAccess
public static function read($variable, $default = null)
{
$session = Container::getSession();
$result = null;
if (isset($session)) {
$result = $session->get($variable);

@ -26,7 +26,6 @@ class Database
*
* @throws \Doctrine\ORM\ORMException
*
* @return
*/
public function connect(
$params = [],
@ -287,17 +286,15 @@ class Database
public static function query($query)
{
$connection = self::getManager()->getConnection();
if (api_get_setting('server_type') == 'test') {
$result = null;
try {
$result = $connection->executeQuery($query);
} else {
try {
$result = $connection->executeQuery($query);
} catch (Exception $e) {
error_log($e->getMessage());
api_not_allowed(false, get_lang('GeneralError'));
}
} catch (Exception $e) {
error_log($e->getMessage());
api_not_allowed(false, get_lang('GeneralError'));
} finally {
return $result;
}
return $result;
}

@ -297,7 +297,6 @@ function api_get_timezones()
/**
* Returns the timezone to be converted to/from, based on user or admin preferences
*
* @return string The timezone chosen
*/
function api_get_timezone()
@ -350,7 +349,6 @@ function api_get_utc_datetime(
$return_null_if_invalid_date = false,
$returnObj = false
) {
$from_timezone = api_get_timezone();
$to_timezone = 'UTC';
if (is_null($time) || empty($time) || $time === '0000-00-00 00:00:00') {
if ($return_null_if_invalid_date) {
@ -371,7 +369,8 @@ function api_get_utc_datetime(
}
try {
$date = new DateTime($time, new DateTimezone($from_timezone));
$fromTimezone = api_get_timezone();
$date = new DateTime($time, new DateTimezone($fromTimezone));
$date->setTimezone(new DateTimeZone($to_timezone));
if ($returnObj) {
return $date;
@ -379,6 +378,7 @@ function api_get_utc_datetime(
return $date->format('Y-m-d H:i:s');
}
} catch (Exception $e) {
error_log($e->getMessage());
return null;
}
}

@ -9,6 +9,7 @@ use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\CoreBundle\Entity\Repository\AccessUrlRepository;
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
use ChamiloSession as Session;
use Chamilo\CoreBundle\Framework\Container;
/**
*
@ -61,29 +62,11 @@ class UserManager
* Create/update/delete methods are available in the UserManager
* (based in the Sonata\UserBundle\Entity\UserManager)
*
* @return Chamilo\UserBundle\Entity\Manager\UserManager
* @return \Sonata\UserBundle\Entity\UserManager
*/
public static function getManager()
{
static $userManager;
if (!isset($userManager)) {
$encoderFactory = self::getEncoderFactory();
$passwordUpdater = new FOS\UserBundle\Util\PasswordUpdater($encoderFactory);
$canonicalUpdater = new FOS\UserBundle\Util\CanonicalFieldsUpdater(
new \FOS\UserBundle\Util\Canonicalizer(),
new \FOS\UserBundle\Util\Canonicalizer()
);
$userManager = new Chamilo\UserBundle\Entity\Manager\UserManager(
$passwordUpdater,
$canonicalUpdater,
Database::getManager(),
User::class
);
}
return $userManager;
return Container::getUserManager();
}
/**
@ -345,7 +328,6 @@ class UserManager
$currentDate = api_get_utc_datetime();
$now = new DateTime();
if (empty($expirationDate) || $expirationDate == '0000-00-00 00:00:00') {
// Default expiration date
// if there is a default duration of a valid account then
@ -367,7 +349,7 @@ class UserManager
/** @var User $user */
$user = $userManager->createUser();
error_log('langua5');
$user
->setLastname($lastName)
->setFirstname($firstName)
@ -391,9 +373,13 @@ class UserManager
if (!empty($expirationDate)) {
$user->setExpirationDate($expirationDate);
}
try {
$userManager->updateUser($user);
$userId = $user->getId();
} catch (Exception $e) {
error_log($e->getMessage());
}
if (!empty($userId)) {
$return = $userId;

@ -57,12 +57,13 @@ putenv("APP_ENV=dev");
putenv("APP_DEBUG=1");
// Calling Symfony container
$kernel = new Chamilo\Kernel('dev', true);
$kernel->boot();
//$kernel = new Chamilo\Kernel('dev', true);
/*$kernel->boot();
$container = $kernel->getContainer();
$oldSession = $container->get('session');
$oldSession->set('s', 's');
Container::setContainer($container);
Container::setContainer($container);*/
session_start();
require_once api_get_path(LIBRARY_PATH).'database.constants.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
@ -75,7 +76,7 @@ $installationLanguage = 'en';
if (!empty($_POST['language_list'])) {
$search = ['../', '\\0'];
$installationLanguage = str_replace($search, '', urldecode($_POST['language_list']));
$_SESSION['install_language'] = $installationLanguage;
//$_SESSION['install_language'] = $installationLanguage;
} else {
// Trying to switch to the browser's language, it is covenient for most of the cases.
$installationLanguage = detect_browser_language();
@ -103,7 +104,7 @@ $_setting = [
'stylesheets' => 'chamilo'
];
$encryptPassForm = '';
$encryptPassForm = 'bcrypt';
$urlAppendPath = '';
$urlForm = '';
$pathForm = '';
@ -116,8 +117,8 @@ $dbPortForm = 3306;
$allowSelfReg = '';
$allowSelfReg = 'approval';
$allowSelfRegProf = 1;
$adminLastName = '';
$adminFirstName = '';
$adminLastName = get_lang('DefaultInstallAdminLastname');
$adminFirstName = get_lang('DefaultInstallAdminFirstname');
$loginForm = 'admin';
$passForm = '';
$institutionUrlForm = 'http://www.chamilo.org';
@ -127,8 +128,8 @@ $educationForm = 'Albert Einstein';
$adminPhoneForm = '(000) 001 02 03';
$institutionForm = 'My Organisation';
$session_lifetime = 360000;
$installLanguage = isset($_SESSION['install_language']) ? $_SESSION['install_language'] : 'english';
//$installLanguage = isset($_SESSION['install_language']) ? $_SESSION['install_language'] : 'english';
$installLanguage = '';
$installationGuideLink = '../../documentation/installation_guide.html';
/*
// Loading language files.
@ -275,8 +276,7 @@ if (!isset($_GET['running'])) {
if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
$emailForm .= '.localdomain';
}
$adminLastName = get_lang('DefaultInstallAdminLastname');
$adminFirstName = get_lang('DefaultInstallAdminFirstname');
$loginForm = 'admin';
$passForm = api_generate_password();
$institutionUrlForm = 'http://www.chamilo.org';
@ -286,24 +286,16 @@ if (!isset($_GET['running'])) {
$userMailCanBeEmpty = 1;
$allowSelfReg = 'approval';
$allowSelfRegProf = 1; //by default, a user can register as teacher (but moderation might be in place)
$encryptPassForm = 'bcrypt';
if (!empty($_GET['profile'])) {
$installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
}
} else {
foreach ($_POST as $key => $val) {
$magic_quotes_gpc = ini_get('magic_quotes_gpc');
if (is_string($val)) {
if ($magic_quotes_gpc) {
$val = stripslashes($val);
}
$val = trim($val);
$_POST[$key] = $val;
} elseif (is_array($val)) {
foreach ($val as $key2 => $val2) {
if ($magic_quotes_gpc) {
$val2 = stripslashes($val2);
}
$val2 = trim($val2);
$_POST[$key][$key2] = $val2;
}
@ -654,10 +646,10 @@ if (@$_POST['step2']) {
<p><?php echo get_lang('CRSTablesIntro') ?></p>
<p>
<button type="button" class="btn btn-warning btn-xs" id="btn-remove-crs-table" data-removing-text="<?php echo get_lang('Removing') ?>" autocomplete="off">
<span class="fa-stack" aria-hidden="true">
<span class="fa fa-circle-thin fa-stack-2x"></span>
<span class="fa fa-trash-o fa-stack-1x"></span>
</span>
<span class="fa-stack" aria-hidden="true">
<span class="fa fa-circle-thin fa-stack-2x"></span>
<span class="fa fa-trash-o fa-stack-1x"></span>
</span>
<?php echo get_lang('CheckForCRSTables') ?>
</button>
</p>
@ -678,7 +670,6 @@ if (@$_POST['step2']) {
}
$('#pnl-check-crs-tables').removeClass('hide');
$('#btn-remove-crs-table').on('click', function (e) {
e.preventDefault();
@ -702,14 +693,12 @@ if (@$_POST['step2']) {
db_port: '<?php echo $dbPortForm; ?>'
}, function () {
$btnRemove.remove();
$btnNext.prop('disabled', false);
});
});
});
});
</script>
<table width="100%">
<tr>
<td>
@ -807,6 +796,7 @@ if (@$_POST['step2']) {
'{{APP_INSTALLED}}' => 1,
'{{APP_ENCRYPT_METHOD}}' => $encryptPassForm
];
updateEnvFile($distFile, $envFile, $params);
(new Dotenv())->load($envFile);
@ -823,18 +813,10 @@ if (@$_POST['step2']) {
if ($result == 0) {
// Boot kernel and get the doctrine from Symfony container
$kernel->boot();
$container = $kernel->getContainer();
$container->set('session', $oldSession);
Container::setContainer($container);
$doctrine = $container->get('doctrine');
$siteManager = $container->get('sonata.page.manager.site');
$manager = $doctrine->getManager();
$containerDatabase = $kernel->getContainer();
$sysPath = api_get_path(SYS_PATH);
$settingsManager = $container->get('chamilo.settings.manager');
finishInstallationWithContainer(
$siteManager,
$settingsManager,
$manager,
$containerDatabase,
$sysPath,
$encryptPassForm,
$passForm,

@ -6,6 +6,8 @@ use Chamilo\TicketBundle\Entity\Project as TicketProject;
use Chamilo\TicketBundle\Entity\Category as TicketCategory;
use Chamilo\TicketBundle\Entity\Priority as TicketPriority;
use Doctrine\ORM\EntityManager;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Framework\Container;
/**
* Chamilo LMS
@ -56,7 +58,8 @@ function isAlreadyInstalledSystem()
* @param string $returnSuccess Text to show when extension is available (defaults to 'Yes')
* @param string $returnFailure Text to show when extension is available (defaults to 'No')
* @param boolean $optional Whether this extension is optional (then show unavailable text in orange rather than red)
* @param string $enabledTerm If this string is not null, then use to check if the corresponding parameter is = 1. If not, mention it's present but not enabled. For example, for opcache, this should be 'opcache.enable'
* @param string $enabledTerm If this string is not null, then use to check if the corresponding parameter is = 1.
* If not, mention it's present but not enabled. For example, for opcache, this should be 'opcache.enable'
* @return string HTML string reporting the status of this extension. Language-aware.
* @author Christophe Gesch??
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
@ -712,12 +715,10 @@ function display_requirements(
echo '</div>';
$properlyAccessUrl = checkAccessUrl();
if (!$properlyAccessUrl) {
echo '
<div class="alert alert-danger">
' . Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_MEDIUM, true, false, true).
' '.
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>&nbsp;'.
sprintf(get_lang('InstallMultiURLDetectedNotMainURL'), api_get_configuration_value('root_web')).'
</div>
';
@ -725,19 +726,11 @@ function display_requirements(
// SERVER REQUIREMENTS
echo '<div class="RequirementHeading"><h4>'.get_lang('ServerRequirements').'</h4>';
$timezone = checkPhpSettingExists("date.timezone");
$timezone = checkPhpSettingExists('date.timezone');
if (!$timezone) {
echo "<div class='alert alert-warning'>".
Display::return_icon(
'warning.png',
get_lang('Warning'),
'',
ICON_SIZE_MEDIUM,
true,
false,
false
).
get_lang("DateTimezoneSettingNotSet")."</div>";
echo "<div class='alert alert-warning'>
<i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i>&nbsp;".
get_lang('DateTimezoneSettingNotSet')."</div>";
}
echo '<div class="RequirementText">'.get_lang('ServerRequirementsInfo').'</div>';
@ -1880,9 +1873,9 @@ function get_countries_list_from_array($combo = false)
*/
function lockSettings()
{
$access_url_locked_settings = api_get_locked_settings();
$settings = api_get_locked_settings();
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
foreach ($access_url_locked_settings as $setting) {
foreach ($settings as $setting) {
$sql = "UPDATE $table SET access_url_locked = 1 WHERE variable = '$setting'";
Database::query($sql);
}
@ -2053,15 +2046,14 @@ function installSettings(
) {
$allowTeacherSelfRegistration = $allowTeacherSelfRegistration ? 'true' : 'false';
// Use PHP 5.3 to avoid issue with weird peripherical auto-installers like travis-ci
$settings = [
'Institution' => $organizationName,
'InstitutionUrl' => $organizationUrl,
'siteName' => $siteName,
'emailAdministrator' => $adminEmail,
'administratorSurname' => $adminLastName,
'administratorName' => $adminFirstName,
'platformLanguage' => $language,
'institution' => $organizationName,
'institution_url' => $organizationUrl,
'site_name' => $siteName,
'administrator_email' => $adminEmail,
'administrator_surname' => $adminLastName,
'administrator_name' => $adminFirstName,
'platform_language' => $language,
'allow_registration' => $allowRegistration,
'allow_registration_as_teacher' => $allowTeacherSelfRegistration,
];
@ -2720,8 +2712,7 @@ function updateEnvFile($distFile, $envFile, $params)
*
* After the schema was created (table creation), the function adds
* admin/platform information.
* @param \Chamilo\CourseBundle\Manager\SettingsManager $settingsManager
* @param EntityManager $manager
* @param \Psr\Container\ContainerInterface $container
* @param string $sysPath
* @param string $encryptPassForm
* @param string $passForm
@ -2739,9 +2730,7 @@ function updateEnvFile($distFile, $envFile, $params)
* @param string $installationProfile Installation profile, if any was provided
*/
function finishInstallationWithContainer(
$siteManager,
$settingsManager,
$manager,
$container,
$sysPath,
$encryptPassForm,
$passForm,
@ -2759,10 +2748,13 @@ function finishInstallationWithContainer(
$installationProfile = ''
) {
$sysPath = !empty($sysPath) ? $sysPath : api_get_path(SYS_PATH);
$connection = $manager->getConnection();
Container::setContainer($container);
Container::setLegacyServices($container);
Database::setConnection($connection);
Database::setManager($manager);
$manager = Database::getManager();
$connection = $manager->getConnection();
$siteManager = Container::getSiteManager();
$settingsManager = Container::getSettingsManager();
$sql = getVersionTable();
@ -2852,7 +2844,7 @@ function finishInstallationWithContainer(
}
// Creating AccessUrl
$accessUrl = new \Chamilo\CoreBundle\Entity\AccessUrl();
$accessUrl = new AccessUrl();
$accessUrl
->setUrl('http://localhost/')
->setDescription('')
@ -2877,7 +2869,7 @@ function finishInstallationWithContainer(
$site->setName('localhost');
$site->setEnabledFrom(new \DateTime('now'));
$site->setEnabledTo(new \DateTime('+20 years'));
$site->setRelativePath("");
$site->setRelativePath('');
$site->setIsDefault(true);
$siteManager->save($site);
@ -2957,7 +2949,7 @@ function finishInstallationWithContainer(
updateDirAndFilesPermissions();
// Set the latest version
$path = $sysPath.'app/Migrations/Schema/V111/';
/*$path = $sysPath.'app/Migrations/Schema/V111/';
$finder = new \Symfony\Component\Finder\Finder();
$files = $finder->files()->in($path);
@ -2968,7 +2960,7 @@ function finishInstallationWithContainer(
$version = str_replace(['Version', '.php'], '', $version->getFilename());
$sql = "INSERT INTO version (version) VALUES ('$version')";
Database::query($sql);
}
}*/
}
/**

@ -8,6 +8,7 @@ require_once __DIR__.'/../main/inc/lib/array.lib.php';
require_once __DIR__.'/../main/inc/lib/database.constants.inc.php';
require_once __DIR__.'/../main/inc/lib/internationalization.lib.php';
require_once __DIR__.'/../main/inc/lib/text.lib.php';
require_once __DIR__.'/../main/inc/lib/banner.lib.php';
require_once __DIR__.'/../main/inc/lib/online.inc.php';
require_once __DIR__.'/../main/inc/lib/fileManage.lib.php';
require_once __DIR__.'/../main/inc/lib/fileUpload.lib.php';

@ -54,6 +54,7 @@ class LegacyListener
// Setting container
Container::setContainer($container);
Container::setLegacyServices($container);
Container::setRequest($request);
// Setting database.

@ -3,18 +3,17 @@
namespace Chamilo\CoreBundle\Framework;
use Sonata\PageBundle\Entity\SiteManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Symfony\Component\Security\Core\Role\RoleHierarchy;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
use Symfony\Component\Templating\Helper\CoreAssetsHelper;
use Chamilo\CoreBundle\Component\Editor\Editor;
use Symfony\Component\Translation\TranslatorInterface;
use Chamilo\SettingsBundle\Manager\SettingsManager;
use Sonata\UserBundle\Entity\UserManager;
/**
* Class Container
@ -36,6 +35,9 @@ class Container
public static $translator;
public static $mailer;
public static $template;
private static $settingsManager;
private static $userManager;
private static $siteManager;
public static $rootDir;
public static $logDir;
@ -205,11 +207,14 @@ class Container
}
/**
* @return Session
* @return Session|false
*/
public static function getSession()
{
return self::$container->get('session');
if (self::$container && self::$container->has('session')) {
return self::$container->get('session');
}
return false;
}
/**
@ -269,11 +274,19 @@ class Container
}
/**
* @return \Chamilo\SettingsBundle\Manager\SettingsManager
* @return SettingsManager
*/
public static function getSettingsManager()
{
return self::$container->get('chamilo.settings.manager');
return self::$settingsManager;
}
/**
* @param SettingsManager $manager
*/
public static function setSettingsManager($manager)
{
self::$settingsManager = $manager;
}
/**
@ -293,12 +306,36 @@ class Container
}
/**
* @return \Sonata\UserBundle\Entity\UserManager
* @return UserManager
*/
public static function getUserManager()
{
//return self::$container->get('sonata.user.user_manager');
return self::$container->get('sonata.user.user_manager');
return self::$userManager;
}
/**
* @param UserManager
*/
public static function setUserManager($manager)
{
self::$userManager = $manager;
}
/**
* @return SiteManager
*/
public static function getSiteManager()
{
return self::$siteManager;
}
/**
* @param UserManager
*/
public static function setSiteManager($manager)
{
self::$siteManager = $manager;
}
/**
@ -350,4 +387,20 @@ class Container
{
return self::$container->get('chamilo_course.tool_chain');
}
/**
* @param ContainerInterface $container
*/
public static function setLegacyServices($container)
{
\Database::setConnection($container->get('doctrine.dbal.default_connection'));
\Database::setManager($container->get('doctrine.orm.entity_manager'));
Container::setSettingsManager($container->get('chamilo.settings.manager'));
Container::setUserManager($container->get('sonata.user.user_manager'));
Container::setSiteManager($container->get('sonata.page.manager.site'));
Container::$session = $container->get('session');
}
}

@ -32,7 +32,8 @@ services:
# Chamilo custom password encoder (depends on the password_encryption param)
chamilo_user.security.encoder:
class: Chamilo\UserBundle\Security\Encoder
arguments: ['%password_encryption%']
arguments:
- '%password_encryption%'
# Course voter checks if a user has permissions to do actions in a course
chamilo_core.security.authorization.voter.course_voter:
@ -194,15 +195,18 @@ services:
# class: Chamilo\CoreBundle\Menu\SimpleMenuBuilder
# arguments: ['@service_container']
# chamilo_core.menu.nav_builder:
# class: Chamilo\CoreBundle\Menu\NavBuilder
# arguments: ['@knp_menu.factory', '@router']
# tags:
# - {name: mopa_bootstrap.menu, alias: chamilo_core.menu.nav}
chamilo_core.menu.nav_builder:
class: Chamilo\CoreBundle\Menu\NavBuilder
calls:
- [setContainer, ['@service_container']]
tags:
- {name: mopa_bootstrap.menu, alias: chamilo_core.menu.nav}
# chamilo_core.menu.course_menu_builder:
# class: Chamilo\CoreBundle\Menu\LeftMenuBuilder
# arguments: ['@knp_menu.factory', '@chamilo_core.entity.manager.course_manager', '@router']
chamilo_core.menu.course_menu_builder:
class: Chamilo\CoreBundle\Menu\LeftMenuBuilder
calls:
- [setContainer, ['@service_container']]
arguments: ['@knp_menu.factory', '@chamilo_core.entity.manager.course_manager', '@router']
# Auth listeners
chamilo_core.listener.login_success_handler:

@ -155,4 +155,9 @@ class Kernel extends BaseKernel
{
return !empty($this->getContainer()->getParameter('installed'));
}
public function getUrlAppend()
{
return $this->getContainer()->getParameter('url_append');
}
}

@ -21,6 +21,7 @@ class Encoder extends BasePasswordEncoder
*/
public function __construct($method)
{
$method = str_replace("'", '', trim($method));
$this->method = $method;
}

@ -1,4 +1,9 @@
msgid "InstallationLanguage"
msgstr "Installation language"
msgid "DefaultInstallAdminFirstname"
msgstr "Joe"
msgid "DefaultInstallAdminLastname"
msgstr "Doe"

Loading…
Cancel
Save