From af3c6d6fd2878cac6ee5615c02c61c6691b7fc63 Mon Sep 17 00:00:00 2001
From: Bertrand Gauthier <bertrand.gauthier@unicaen.fr>
Date: Tue, 20 Mar 2018 10:01:12 +0100
Subject: [PATCH] =?UTF-8?q?Le=20service=20UserContext=20est=20d=C3=A9sorma?=
 =?UTF-8?q?is=20construit=20par=20une=20factory?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 config/module.config.php                      |  3 ++-
 .../Service/UserContextFactory.php            | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 src/UnicaenAuth/Service/UserContextFactory.php

diff --git a/config/module.config.php b/config/module.config.php
index b0b657e..b015ae6 100644
--- a/config/module.config.php
+++ b/config/module.config.php
@@ -3,6 +3,7 @@
 use UnicaenAuth\Controller\AuthControllerFactory;
 use UnicaenAuth\Service\ShibService;
 use UnicaenAuth\Service\ShibServiceFactory;
+use UnicaenAuth\Service\UserContextFactory;
 use UnicaenAuth\View\Helper\ShibConnectViewHelperFactory;
 
 $settings = [
@@ -373,7 +374,6 @@ return [
             'UnicaenAuth\Authentication\Storage\Ldap' => 'UnicaenAuth\Authentication\Storage\Ldap',
             'UnicaenAuth\Authentication\Storage\Shib' => 'UnicaenAuth\Authentication\Storage\Shib',
             'UnicaenAuth\View\RedirectionStrategy'    => 'UnicaenAuth\View\RedirectionStrategy',
-            'UnicaenAuth\Service\UserContext'         => 'UnicaenAuth\Service\UserContext',
             'UnicaenAuth\Service\User'                => 'UnicaenAuth\Service\User',
             'UnicaenAuth\Service\CategoriePrivilege'  => 'UnicaenAuth\Service\CategoriePrivilegeService',
         ],
@@ -396,6 +396,7 @@ return [
             'BjyAuthorize\Service\Authorize'           => 'UnicaenAuth\Service\AuthorizeServiceFactory', // substituion
             'zfcuser_redirect_callback'                => 'UnicaenAuth\Authentication\RedirectCallbackFactory', // substituion
             ShibService::class                         => ShibServiceFactory::class,
+            'UnicaenAuth\Service\UserContext'          => UserContextFactory::class,
             'MouchardCompleterAuth'        => 'UnicaenAuth\Mouchard\MouchardCompleterAuthFactory',
         ],
         'shared' => [
diff --git a/src/UnicaenAuth/Service/UserContextFactory.php b/src/UnicaenAuth/Service/UserContextFactory.php
new file mode 100644
index 0000000..cec7997
--- /dev/null
+++ b/src/UnicaenAuth/Service/UserContextFactory.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace UnicaenAuth\Service;
+
+use Zend\ServiceManager\ServiceLocatorInterface;
+
+class UserContextFactory
+{
+    /**
+     * @param ServiceLocatorInterface $sl
+     * @return UserContext
+     */
+    public function __invoke(ServiceLocatorInterface $sl)
+    {
+        $service = new UserContextService();
+
+        return $service;
+    }
+}
\ No newline at end of file
-- 
GitLab