Commit 2179e160 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Merge branch 'master' of https://git.unicaen.fr/lib/unicaen/app into laminas_migration

 Conflicts:
	config/module.config.php
	src/UnicaenApp/Session/SessionManagerFactory.php
	tests/UnicaenAppTest/Session/SessionManagerFactoryTest.php
parents d77dc593 d0b463ad
Pipeline #11532 failed with stages
in 1 minute
CHANGELOG
=========
3.1.23
------
- Suppression de la SessionManagerFactory jamais utilisée car mal configurée.
3.1.22
------
- Le composant TabAjax ajoute les urls dans les attributs data-url des tab-panes
3.1.21
------
- Dépendance composer supprimée : zfcampus/zf-asset-manager.
......
......@@ -281,8 +281,6 @@ return [
'factories' => [
'translator' => 'Laminas\I18n\Translator\TranslatorServiceFactory',
'navigation' => 'Laminas\Navigation\Service\DefaultNavigationFactory',
// service de gestion de la session
'Laminas\Session\SessionManager' => 'UnicaenApp\Session\SessionManagerFactory',
// service d'accès aux options de config de ce module
'unicaen-app_module_options' => 'UnicaenApp\Options\ModuleOptionsFactory',
// mapper d'accès aux individus de l'annuaire LDAP
......
<?php
namespace UnicaenApp\Session;
use Interop\Container\ContainerInterface;
use UnicaenApp\Options\ModuleOptions;
use Laminas\Session\Config\SessionConfig;
use Laminas\Session\SessionManager;
use Laminas\Session\Validator\HttpUserAgent;
use Laminas\Session\Validator\RemoteAddr;
/**
* Description of SessionManager
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class SessionManagerFactory
{
public function __invoke(ContainerInterface $container)
{
/** @var ModuleOptions $moduleOptions */
$moduleOptions = $container->get('unicaen-app_module_options');
$appInfos = $moduleOptions->getAppInfos();
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions([
'name' => md5($appInfos['nom']),
]);
$sessionManager = new SessionManager($sessionConfig);
$chain = $sessionManager->getValidatorChain();
$chain->attach('session.validate', array(new RemoteAddr(), 'isValid'));
$chain->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
return $sessionManager;
}
}
\ No newline at end of file
......@@ -293,9 +293,10 @@ class TabAjaxViewHelper extends AbstractHtmlElement
$id = $tab->getId() ?: 'tab' . $index;
$attrs = [
'role' => 'tabpanel',
'class' => ['tab-pane'],
'id' => $id,
'role' => 'tabpanel',
'class' => ['tab-pane'],
'data-url' => $tab->getUrl(),
'id' => $id,
];
if ($this->getSelected() === $tab) $attrs['class'][] = 'active';
......
<?php
namespace UnicaenAppTest\Session;
use UnicaenApp\Options\ModuleOptions;
use UnicaenApp\Session\SessionManagerFactory;
use UnicaenAppTest\BaseServiceFactoryTest;
use Laminas\Session\Container;
use Laminas\Session\SessionManager;
/**
* Description of ModuleOptionsFactoryTest
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class ModuleOptionsFactoryTest extends BaseServiceFactoryTest
{
/**
* @var SessionManagerFactory
*/
protected $factory;
protected $factoryClass = SessionManagerFactory::class;
protected $serviceClass = SessionManager::class;
public function testCanCreateService()
{
$appInfos = [
'nom' => "Mon application",
];
$moduleOptions = $this->createMock(ModuleOptions::class);
$moduleOptions
->expects($this->once())
->method('getAppInfos')
->willReturn($appInfos);
$this->serviceManager
->expects($this->once())
->method('get')
->with('unicaen-app_module_options')
->willReturn($moduleOptions);
$service = $this->factory->__invoke($this->serviceManager);
/* @var $service \Laminas\Session\SessionManager */
$this->assertInstanceOf($this->serviceClass, $service);
$this->assertNotEmpty($service->getValidatorChain()->getListeners('session.validate'));
$this->assertEquals($service->getConfig()->getName(), md5($appInfos['nom']));
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment