N°2060: Fix data-localizer and archive mode initialization for Symfony portal

This commit is contained in:
Stephen Abello
2019-10-17 10:10:49 +02:00
parent ce207e5c56
commit 0a2063ce69
4 changed files with 58 additions and 2 deletions

View File

@@ -67,11 +67,13 @@ services:
# Tag services without defining them (see https://symfony.com/doc/current/service_container/tags.html#autoconfiguring-tags)
_instanceof:
Combodo\iTop\Portal\EventListener\UserProvider:
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
tags: [{ name: 'kernel.event_listener', event: 'kernel.request', priority: 500 }]
calls:
- [setContainer, ['@service_container']]
Combodo\iTop\Portal\EventListener\ApplicationContextSetUrlMakerClass:
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
tags: [{ name: 'kernel.event_listener', event: 'kernel.request', priority: 400 }]
Combodo\iTop\Portal\EventListener\ApplicationContextSetPluginPropertyClass:
tags: [{ name: 'kernel.event_listener', event: 'kernel.request', priority: 300 }]
# Add more service definitions when explicit configuration is needed
# Please note that last definitions always *replace* previous ones

View File

@@ -0,0 +1,52 @@
<?php
/**
*
* * Copyright (C) 2013-2019 Combodo SARL
* *
* * This file is part of iTop.
* *
* * iTop is free software; you can redistribute it and/or modify
* * it under the terms of the GNU Affero General Public License as published by
* * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* *
* * iTop is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU Affero General Public License for more details.
* *
* * You should have received a copy of the GNU Affero General Public License
*
*/
namespace Combodo\iTop\Portal\EventListener;
use ApplicationContext;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use UserRights;
use utils;
/**
* Class ApplicationContextSetPluginPropertyClass
*
* @package Combodo\iTop\Portal\EventListener
* @since 2.7.0
* @author Stephen Abello <stephen.abello@combodo.com>
*/
class ApplicationContextSetPluginPropertyClass
{
/**
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $oGetResponseEvent
*/
public function onKernelRequest(GetResponseEvent $oGetResponseEvent)
{
// Enable archived data
utils::InitArchiveMode();
// Enabling datalocalizer if needed
if (!defined('DISABLE_DATA_LOCALIZER_PORTAL'))
{
ApplicationContext::SetPluginProperty('QueryLocalizerPlugin', 'language_code', UserRights::GetUserLanguage());
}
}
}

View File

@@ -31,6 +31,7 @@ return array(
'Combodo\\iTop\\Portal\\DependencyInjection\\SilexCompatBootstrap\\PortalXmlConfiguration\\Forms' => $baseDir . '/src/DependencyInjection/SilexCompatBootstrap/PortalXmlConfiguration/Forms.php',
'Combodo\\iTop\\Portal\\DependencyInjection\\SilexCompatBootstrap\\PortalXmlConfiguration\\Lists' => $baseDir . '/src/DependencyInjection/SilexCompatBootstrap/PortalXmlConfiguration/Lists.php',
'Combodo\\iTop\\Portal\\EventListener\\ApplicationContextSetUrlMakerClass' => $baseDir . '/src/EventListener/ApplicationContextSetUrlMakerClass.php',
'Combodo\\iTop\\Portal\\EventListener\\ApplicationContextSetPluginPropertyClass' => $baseDir . '/src/EventListener/ApplicationContextSetPluginPropertyClass.php',
'Combodo\\iTop\\Portal\\EventListener\\UserProvider' => $baseDir . '/src/EventListener/UserProvider.php',
'Combodo\\iTop\\Portal\\Form\\ObjectFormManager' => $baseDir . '/src/Form/ObjectFormManager.php',
'Combodo\\iTop\\Portal\\Form\\PasswordFormManager' => $baseDir . '/src/Form/PasswordFormManager.php',

View File

@@ -51,6 +51,7 @@ class ComposerStaticInitdf408f3f8ea034d298269cdf7647358b
'Combodo\\iTop\\Portal\\DependencyInjection\\SilexCompatBootstrap\\PortalXmlConfiguration\\Forms' => __DIR__ . '/../..' . '/src/DependencyInjection/SilexCompatBootstrap/PortalXmlConfiguration/Forms.php',
'Combodo\\iTop\\Portal\\DependencyInjection\\SilexCompatBootstrap\\PortalXmlConfiguration\\Lists' => __DIR__ . '/../..' . '/src/DependencyInjection/SilexCompatBootstrap/PortalXmlConfiguration/Lists.php',
'Combodo\\iTop\\Portal\\EventListener\\ApplicationContextSetUrlMakerClass' => __DIR__ . '/../..' . '/src/EventListener/ApplicationContextSetUrlMakerClass.php',
'Combodo\\iTop\\Portal\\EventListener\\ApplicationContextSetPluginPropertyClass' => __DIR__ . '/../..' . '/src/EventListener/ApplicationContextSetPluginPropertyClass.php',
'Combodo\\iTop\\Portal\\EventListener\\UserProvider' => __DIR__ . '/../..' . '/src/EventListener/UserProvider.php',
'Combodo\\iTop\\Portal\\Form\\ObjectFormManager' => __DIR__ . '/../..' . '/src/Form/ObjectFormManager.php',
'Combodo\\iTop\\Portal\\Form\\PasswordFormManager' => __DIR__ . '/../..' . '/src/Form/PasswordFormManager.php',