*/ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, ServiceProviderInterface { /** * * @return array * @see ConfigProviderInterface */ public function getConfig() { return include __DIR__ . '/config/module.config.php'; } /** * * @return array * @see AutoloaderProviderInterface */ public function getAutoloaderConfig() { return array( 'Zend\Loader\ClassMapAutoloader' => array( __DIR__ . '/autoload_classmap.php', ), 'Zend\Loader\StandardAutoloader' => array( 'namespaces' => array( __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, ), ), ); } /** * This method is called once the MVC bootstrapping is complete, * after the "loadModule.post" event, once $application->bootstrap() is called. * * @param EventInterface $e * @see BootstrapListenerInterface */ public function onBootstrap(\Zend\EventManager\EventInterface $e) /* @var \Zend\Mvc\MvcEvent $e */ { $application = $e->getApplication(); /* @var $services \Zend\ServiceManager\ServiceManager */ $services = $application->getServiceManager(); // transmission des ACL aux aides de vue de navigation try { $authorizeService = $services->get('BjyAuthorize\Service\Authorize'); /* @var $authorizeService \BjyAuthorize\Service\Authorize */ \Zend\View\Helper\Navigation::setDefaultAcl($authorizeService->getAcl()); \Zend\View\Helper\Navigation::setDefaultRole($authorizeService->getIdentity()); } catch (\Zend\ServiceManager\Exception\ServiceNotFoundException $snfe) { // pas de module BjyAuthorize : pas d'ACL } /* @var $options Options\ModuleOptions */ $options = $services->get('unicaen-auth_module_options'); // si l'auth CAS est demandée, modif de la route de connexion pour zapper le formulaire if ($options->getCas() && php_sapi_name() !== 'cli') { /* @var $router \Zend\Mvc\Router\Http\TreeRouteStack */ $router = $services->get('router'); $router->addRoutes(array( // remplace les routes existantes (cf. config du module) 'zfcuser' => array( 'type' => 'Literal', 'priority' => 1000, 'options' => array( 'route' => '/auth', 'defaults' => array( 'controller' => 'zfcuser', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'login' => array( 'type' => 'Literal', 'options' => array( 'route' => '/connexion', 'defaults' => array( 'controller' => 'zfcuser', 'action' => 'authenticate', // zappe l'action 'login' ), ), ), 'logout' => array( 'type' => 'Literal', 'options' => array( 'route' => '/deconnexion', 'defaults' => array( 'controller' => 'zfcuser', 'action' => 'logout', ), ), ), ), ) )); } } /** * * @return array * @see ViewHelperProviderInterface */ public function getViewHelperConfig() { return array( 'factories' => array( 'appConnection' => function (HelperPluginManager $sm) { return new View\Helper\AppConnection(); }, 'userConnection' => function (HelperPluginManager $sm) { return new View\Helper\UserConnection($sm->getServiceLocator()->get('zfcuser_auth_service')); }, 'userCurrent' => function (HelperPluginManager $sm) { return new View\Helper\UserCurrent($sm->getServiceLocator()->get('zfcuser_auth_service')); }, 'userStatus' => function (HelperPluginManager $sm) { return new View\Helper\UserStatus($sm->getServiceLocator()->get('zfcuser_auth_service')); }, 'userProfile' => function (HelperPluginManager $sm) { $helper = new View\Helper\UserProfile($sm->getServiceLocator()->get('zfcuser_auth_service')); $helper->setIdentityProvider($sm->getServiceLocator()->get('BjyAuthorize\Service\Authorize')->getIdentityProvider()); return $helper; }, 'userInfo' => function (HelperPluginManager $sm) { $helper = new View\Helper\UserInfo($sm->getServiceLocator()->get('zfcuser_auth_service')); $helper->setMapperStructure($sm->getServiceLocator()->get('ldap_structure_mapper')); return $helper; }, ), ); } /** * * @return array * @see ServiceProviderInterface */ public function getServiceConfig() { return array( 'factories' => array( 'zfcuser_user_mapper' => function ($sm) { $config = $sm->get('configuration'); $em = isset($config['doctrine']['connection']['orm_auth']) ? 'doctrine.entitymanager.orm_auth' : 'doctrine.entitymanager.orm_default'; return new \ZfcUserDoctrineORM\Mapper\User( $sm->get($em), $sm->get('zfcuser_module_options') ); }, 'unicaen-auth_user_service' => function () { return new Service\User(); }, 'UnicaenAuth\Provider\Identity\LdapPeople' => function($sm) { $authService = $sm->get('zfcuser_auth_service'); $provider = new \UnicaenAuth\Provider\Identity\LdapPeople($authService); return $provider; }, ), ); } }