LdapFactory.php 1.02 KB
Newer Older
1
2
3
4
5
6
<?php

namespace UnicaenAuth\Authentication\Storage;

use Interop\Container\ContainerInterface;
use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper;
7
use UnicaenAuth\Authentication\Adapter\Ldap as LdapAdapter;
8
use UnicaenAuth\Options\ModuleOptions;
Bertrand Gauthier's avatar
Bertrand Gauthier committed
9
10
use Laminas\Authentication\Storage\Session;
use Laminas\Session\SessionManager;
11

12
class LdapFactory
13
{
14
    public function __invoke(ContainerInterface $container, $requestedName, array $moduleOptions = null)
15
16
17
18
    {
        /** @var LdapPeopleMapper $mapper */
        $mapper = $container->get('ldap_people_mapper');

19
20
        /** @var ModuleOptions $moduleOptions */
        $moduleOptions = $container->get('unicaen-auth_module_options');
21

22
23
24
        /** @var SessionManager $sessionManager */
        $sessionManager = $container->get(SessionManager::class);

25
        $storage = new Ldap();
26
        $storage->setStorage(new Session(LdapAdapter::class, null, $sessionManager));
27
        $storage->setMapper($mapper);
28
        $storage->setModuleOptions($moduleOptions);
29
30
31
32

        return $storage;
    }
}