GenericFactory.php 1.6 KB
Newer Older
1
2
3
4
<?php

namespace UnicaenLdap\Service;

5
use Interop\Container\ContainerInterface;
6
7
use UnicaenLdap\Ldap;
use UnicaenLdap\Service;
8
9
10
11
12
13
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class GenericFactory implements FactoryInterface
{
    public function createService(ServiceLocatorInterface $serviceLocator)
14
15
16
17
    {
        return $this->__invoke($serviceLocator, '?');
    }

18
19
20
21
22
23
24
25
    /**
     * Create service
     *
     * @param ContainerInterface $container
     * @param string $requestedName
     * @param array|null $options
     * @return object|Generic
     */
26
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
27
    {
28
29
30
31
32
33
34
        /**
         * @var Ldap $ldap
         * @var Service\People $ldapPeopleService
         * @var Service\Structure $ldapStructureService
         * @var Service\Group $ldapGroupService
         * @var Service\System $ldapSystemService
         */
35
        $ldap = $container->get('ldap');
36
37
38
39
        $ldapPeopleService      = $container->get('ldapServicePeople');
        $ldapStructureService   = $container->get('ldapServiceStructure');
        $ldapGroupService       = $container->get('ldapServiceGroup');
        $ldapSystemService      = $container->get('ldapServiceSystem');
40

41
        $service = new Generic();
42
        $service->setLdap($ldap);
43
44
45
46
        $service->setLdapPeopleService($ldapPeopleService);
        $service->setLdapStructureService($ldapStructureService);
        $service->setLdapGroupService($ldapGroupService);
        $service->setLdapSystemService($ldapSystemService);
47
48
49
50

        return $service;
    }
}