Skip to content
Snippets Groups Projects
Select Git revision
  • 2dca4963d882e9e9ea590a34ed22de3b6d922941
  • master default protected
  • 5.x
  • 7
  • 6.0.question
  • bg-php8
  • release_3.1.0
  • release_4.0.0
  • zf-3.0
  • zf-3.x
  • 5.0.8
  • 5.0.7
  • 6.0.5
  • 5.0.6
  • 6.0.4
  • 5.0.5
  • 7.0.3
  • 7.0.2
  • 6.0.3
  • 6.0.2
  • 6.0.1
  • 5.0.4
  • 7.0.1
  • 5.0.3
  • 5.0.2
  • 5.0.1
  • 7.0.0
  • 6.0.0
  • 4.0.2
  • 5.0.0
30 results

GenericFactory.php

  • GenericFactory.php 1.60 KiB
    <?php
    
    namespace UnicaenLdap\Service;
    
    use Interop\Container\ContainerInterface;
    use UnicaenLdap\Ldap;
    use UnicaenLdap\Service;
    use Zend\ServiceManager\FactoryInterface;
    use Zend\ServiceManager\ServiceLocatorInterface;
    
    class GenericFactory implements FactoryInterface
    {
        public function createService(ServiceLocatorInterface $serviceLocator)
        {
            return $this->__invoke($serviceLocator, '?');
        }
    
        /**
         * Create service
         *
         * @param ContainerInterface $container
         * @param string $requestedName
         * @param array|null $options
         * @return object|Generic
         */
        public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
        {
            /**
             * @var Ldap $ldap
             * @var Service\People $ldapPeopleService
             * @var Service\Structure $ldapStructureService
             * @var Service\Group $ldapGroupService
             * @var Service\System $ldapSystemService
             */
            $ldap = $container->get('ldap');
            $ldapPeopleService      = $container->get('ldapServicePeople');
            $ldapStructureService   = $container->get('ldapServiceStructure');
            $ldapGroupService       = $container->get('ldapServiceGroup');
            $ldapSystemService      = $container->get('ldapServiceSystem');
    
            $service = new Generic();
            $service->setLdap($ldap);
            $service->setLdapPeopleService($ldapPeopleService);
            $service->setLdapStructureService($ldapStructureService);
            $service->setLdapGroupService($ldapGroupService);
            $service->setLdapSystemService($ldapSystemService);
    
            return $service;
        }
    }