Skip to content
Snippets Groups Projects
Select Git revision
  • 63e25879c1e21a4f79f04443f2947e58b09b6c7b
  • master default protected
  • cleanup_fixtures
  • add-openvox
  • freebsd-14
  • remove-legacy-top-scope-syntax
  • rel430
  • tests
  • revert-363-augeas-module-cleanup
  • release-4.1.0
  • puppet8
  • relax-dependencies
  • rel400
  • mode
  • puppet7
  • release-3.1.0
  • freebsd13
  • freebsd11
  • stdlib
  • centos
  • fedora
  • v5.1.0
  • v5.0.0
  • v4.5.0
  • v4.4.0
  • v4.3.0
  • v4.2.1
  • v4.2.0
  • v4.1.0
  • v4.0.0
  • v3.1.0
  • v3.0.0
  • v2.0.0
  • 1.12.0
  • 1.11.0
  • 1.10.0
  • 1.9.0
  • 1.8.0
  • 1.7.0
  • 1.6.0
  • 1.5.0
41 results

postfix_spec.rb

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Module.php 3.36 KiB
    <?php
    
    namespace UnicaenAuth;
    
    use Laminas\EventManager\EventInterface;
    use Laminas\ModuleManager\Feature\AutoloaderProviderInterface;
    use Laminas\ModuleManager\Feature\BootstrapListenerInterface;
    use Laminas\ModuleManager\Feature\ConfigProviderInterface;
    use Laminas\ModuleManager\Feature\ServiceProviderInterface;
    use Laminas\Mvc\MvcEvent;
    use UnicaenAuth\Event\Listener\LdapAuthenticationFailureLoggerListener;
    use UnicaenAuth\Options\ModuleOptions;
    
    /**
     * Point d'entrée du module d'authentification Unicaen.
     *
     * @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
     */
    class Module implements AutoloaderProviderInterface, ConfigProviderInterface, ServiceProviderInterface, BootstrapListenerInterface
    {
        /**
         * @var \UnicaenAuth\Options\ModuleOptions
         */
        private $moduleOptions;
    
        /**
         * @var \Laminas\EventManager\EventManagerInterface
         */
        private $eventManager;
    
        /**
         * @var \Laminas\ServiceManager\ServiceManager
         */
        private $serviceManager;
    
        /**
         * @return array
         * @see ConfigProviderInterface
         */
        public function getConfig()
        {
            return include __DIR__ . '/config/module.config.php';
        }
    
        /**
         * @return array
         * @see AutoloaderProviderInterface
         */
        public function getAutoloaderConfig()
        {
            return [
                'Laminas\Loader\StandardAutoloader' => [
                    'namespaces' => [
                        __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                    ],
                ],
            ];
        }
    
        /**
         * @inheritDoc
         */
        public function onBootstrap(EventInterface $e)
        {
            if ($e instanceof MvcEvent) {
                /** @var \Laminas\Mvc\Application $application */
                $application = $e->getApplication();
                $this->serviceManager = $application->getServiceManager();
                $this->eventManager = $application->getEventManager();
                $this->moduleOptions = $this->serviceManager->get(ModuleOptions::class);
    
                $this->attachEventListeners();
            }
        }
    
        protected function attachEventListeners()
        {
            // log éventuel des erreurs d'authentification LDAP
            $logLdapAuthenticationFailure = $this->moduleOptions->getLdap()['log_failures'] ?? false;
            if ($logLdapAuthenticationFailure) {
                /** @var LdapAuthenticationFailureLoggerListener $listener */
                $listener = $this->serviceManager->get(LdapAuthenticationFailureLoggerListener::class);
                $listener->attach($this->eventManager);
            }
        }
    
        /**
         * @return array
         * @see ServiceProviderInterface
         */
        public function getServiceConfig()
        {
            return [
                //========== repris du module zf-commons/zfc-user-doctrine-orm abandonné =========
                'aliases' => array(
                    'zfcuser_doctrine_em' => 'Doctrine\ORM\EntityManager',
                ),
                //===========================================
    
    
                'factories' => [
                    //========== repris du module zf-commons/zfc-user-doctrine-orm abandonné =========
                    'zfcuser_module_options' => function ($sm) {
                        $config = $sm->get('Configuration');
                        return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array());
                    },
                    //===========================================
    
                ],
            ];
        }
    }