ShibFactory.php 1.14 KB
Newer Older
1
2
3
4
5
<?php

namespace UnicaenAuth\Authentication\Storage;

use Interop\Container\ContainerInterface;
6
use UnicaenAuth\Options\ModuleOptions;
7
use UnicaenAuth\Service\ShibService;
8
use Zend\Authentication\Storage\Session;
9
use Zend\Session\SessionManager;
10

11
class ShibFactory
12
{
13
14
15
16
17
18
19
    /**
     * @param ContainerInterface $container
     * @param string $requestedName
     * @param array|null $moduleOptions
     * @return Shib
     */
    public function __invoke(ContainerInterface $container, string $requestedName, array $moduleOptions = null)
20
21
22
23
    {
        /** @var ShibService $shibService */
        $shibService = $container->get(ShibService::class);

24
25
26
        /** @var ModuleOptions $moduleOptions */
        $moduleOptions = $container->get('unicaen-auth_module_options');

27
28
29
        /** @var SessionManager $sessionManager */
        $sessionManager = $container->get(SessionManager::class);

30
        $storage = new Shib();
31
        $storage->setStorage(new Session(\UnicaenAuth\Authentication\Adapter\Shib::class, null, $sessionManager));
32
        $storage->setShibService($shibService);
33
        $storage->setModuleOptions($moduleOptions);
34
35
36
37

        return $storage;
    }
}