示例#1
0
 public function onBootstrap(MvcEvent $e)
 {
     $app = $e->getApplication();
     $eventManager = $app->getEventManager();
     $sm = $app->getServiceManager();
     // initialize SessionManager
     $this->bootstrapSession($e);
     // Attach UserListener for role and UserProfile handling
     $listener = $sm->get(UserListener::class);
     $eventManager->attach($listener);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'initTranslator'), -100);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'setUserLanguage'));
     // Enable BjyAuthorize when not in console mode
     if (!\Zend\Console\Console::isConsole()) {
         // Add ACL information to the Navigation view helper
         $authorize = $sm->get(Authorize::class);
         $acl = $authorize->getAcl();
         $role = $authorize->getIdentity();
         Navigation::setDefaultAcl($acl);
         Navigation::setDefaultRole($role);
     }
     /* @var $translator \Zend\I18n\Translator\Translator */
     $translator = $e->getApplication()->getServiceManager()->get('MvcTranslator');
     // add Db Loader factory
     $translator->getPluginManager()->setFactory(I18n\Translator\Loader\Db::class, I18n\Translator\Loader\Factory\DbFactory::class);
     if ($e->getRouter() instanceof \Zend\Mvc\Router\Http\TranslatorAwareTreeRouteStack) {
         $e->getRouter()->setTranslator($translator);
     }
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config.helper')->get('acl');
     $acl = new Acl();
     foreach ($config['roles'] as $role => $parents) {
         if (empty($parents)) {
             $parents = null;
         }
         $role = new GenericRole($role);
         $acl->addRole($role, $parents);
     }
     foreach ($config['resources'] as $permission => $controllers) {
         foreach ($controllers as $controller => $actions) {
             if (!$acl->hasResource($controller)) {
                 $acl->addResource(new GenericResource($controller));
             }
             foreach ($actions as $action => $role) {
                 if ($action == '*') {
                     $action = null;
                 }
                 if ($permission == 'allow') {
                     $acl->allow($role, $controller, $action);
                 } elseif ($permission == 'deny') {
                     $acl->deny($role, $controller, $action);
                 } else {
                     throw new Exception('No valid permission defined: ' . $permission);
                 }
             }
         }
     }
     if (class_exists('Zend\\View\\Helper\\Navigation')) {
         Navigation::setDefaultAcl($acl);
     }
     return $acl;
 }
示例#3
0
 public function onBootstrap(MvcEvent $e)
 {
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // Add translation
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $setLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     } else {
         $setLang = '';
     }
     $translator->setLocale(\Locale::acceptFromHttp($setLang))->setFallbackLocale('en_US');
     // Add ACL information to the Navigation view helper
     $sm = $e->getApplication()->getServiceManager();
     $authorize = $sm->get('BjyAuthorize\\Service\\Authorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) use($sm) {
         if ($e->getParam('exception')) {
             $sm->get('Zend\\Log\\Logger')->crit($e->getParam('exception'));
         }
     });
 }
示例#4
0
 protected function inject(\Zend\View\Helper\Navigation\HelperInterface $helper)
 {
     parent::inject($helper);
     if ($helper instanceof Navigation || $helper instanceof Menu) {
         $helper->setRoles($this->getRoles());
     }
 }
示例#5
0
    /**
     * @group ZF-6854
     */
    public function testRenderInvisibleItem()
    {
        $container = new \Zend\Navigation\Navigation(array(
            array(
                'label' => 'Page 1',
                'id'    => 'p1',
                'uri'   => 'p1'
            ),
            array(
                'label'   => 'Page 2',
                'id'      => 'p2',
                'uri'     => 'p2',
                'visible' => false
            )
        ));

        $render = $this->_helper->menu()->render($container);

        $this->assertFalse(strpos($render, 'p2'));

        $this->_helper->menu()->setRenderInvisible();

        $render = $this->_helper->menu()->render($container);

        $this->assertTrue(strpos($render, 'p2') !== false);
    }
示例#6
0
文件: Module.php 项目: omusico/Base
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $request = $e->getApplication()->getServiceManager()->get('Request');
     $moduleRouteListener->attach($eventManager);
     $adapter = $e->getApplication()->getServiceManager()->get('Zend\\Db\\Adapter\\Adapter');
     $config = $e->getApplication()->getServiceManager()->get('Configuration');
     $locale = null;
     $eventManager->attach(new UserRegisterListener($adapter));
     $eventManager->attach(new LogListener());
     // Add ACL information to the Navigation view helper
     $authorize = $e->getApplication()->getServiceManager()->get('BjyAuthorize\\Service\\Authorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     // translating system
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     $session = new Container('base');
     // Get the visitor language selection
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     // get the locale from the cookie
     $headCookie = $request->getHeaders()->get('Cookie');
     if (!empty($headCookie) && array_key_exists('locale', get_object_vars($headCookie))) {
         $locale = $headCookie->locale;
     }
     if (empty($locale)) {
         // if there is not set any cookie
         $locale = $session->offsetGet('locale');
         // Get the locale from the session
         if (empty($locale)) {
             // if there is not any session set yet
             $headers = $request->getHeaders();
             if ($headers->has('Accept-Language')) {
                 $locales = $headers->get('Accept-Language')->getPrioritized();
                 $first = array_shift($locales);
                 $locale = $first->getLanguage();
                 if (!empty($locale) && 2 == strlen($locale)) {
                     $locale .= "_" . strtoupper($locale);
                 }
             }
             if (empty($locale)) {
                 // if the browser has no locale set, we have to get the default INTL global locale setting
                 $locale = \Locale::getPrimaryLanguage(\Locale::getDefault());
                 // Gets the default locale value from the INTL global 'default_locale'
             }
         }
     } else {
         #\Zend\Debug\debug::dump("Cookie set with locale: $locale");
     }
     $translator->setLocale(\Locale::acceptFromHttp($locale));
     $translator->setLocale($locale)->setFallbackLocale('en_US');
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain();
 }
示例#7
0
 public function getPluginManager()
 {
     $pm = parent::getPluginManager();
     foreach ($this->defaultHelpers as $name => $invokableClass) {
         $pm->setInvokableClass($name, $invokableClass);
     }
     return $pm;
 }
示例#8
0
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $sm = $e->getApplication()->getServiceManager();
     // Add ACL information to the Navigation view helper
     $authorize = $sm->get('BjyAuthorizeServiceAuthorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     Navigation::setDefaultAcl($acl);
     Navigation::setDefaultRole($role);
 }
示例#9
0
 public function onBootstrap(EventInterface $e)
 {
     /* @var $application \Zend\Mvc\Application */
     $application = $e->getTarget();
     $eventManager = $application->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     //todo Delete this hack (avoid unit tests) after update BjyAuthorize module to 2.0
     if (\Zend\Console\Console::isConsole()) {
         return;
     }
     $sm = $e->getApplication()->getServiceManager();
     // Add ACL information to the Navigation view helper
     $authorize = $sm->get('BjyAuthorizeServiceAuthorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     ZendViewHelperNavigation::setDefaultAcl($acl);
     ZendViewHelperNavigation::setDefaultRole($role);
     $services = $application->getServiceManager();
     $zfcServiceEvents = $services->get('zfcuser_user_service')->getEventManager();
     $zfcServiceEvents->attach('register', function ($e) use($services) {
         $zfcUser = $e->getParam('user');
         $em = $services->get('doctrine.entitymanager.orm_default');
         $configAuth = $services->get('BjyAuthorize\\Config');
         $providerConfig = $configAuth['role_providers']['BjyAuthorize\\Provider\\Role\\ObjectRepositoryProvider'];
         $criteria = array('roleId' => $configAuth['authenticated_role']);
         $defaultUserRole = $em->getRepository($providerConfig['role_entity_class'])->findOneBy($criteria);
         if ($defaultUserRole !== null) {
             $zfcUser->addRole($defaultUserRole);
         }
     });
     $application->getEventManager()->getSharedManager()->attach('ZfcUserAdmin\\Form\\EditUser', 'init', function ($e) {
         // $form is a ZfcUser\Form\Register
         $form = $e->getTarget();
         $sm = $form->getServiceManager();
         $om = $sm->get('Doctrine\\ORM\\EntityManager');
         //$form->setHydrator(new \DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity($om, 'OpsWay\TocatUser\Entity\User'));
         $form->add(array('name' => 'roles', 'type' => 'DoctrineModule\\Form\\Element\\ObjectMultiCheckbox', 'options' => array('label' => 'Assign Roles', 'object_manager' => $om, 'target_class' => Entity\Role::class, 'property' => 'roleId')));
         $form->add(array('name' => 'groups', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'options' => array('label' => 'Assign Groups', 'object_manager' => $om, 'target_class' => Entity\Group::class, 'property' => 'name'), 'attributes' => array('multiple' => true)));
     });
     $application->getEventManager()->getSharedManager()->attach('ZfcUserAdmin\\Service\\User', 'edit', function ($e) {
         $zfcUser = $e->getParam('user');
         $post = $e->getParam('data');
         $em = $e->getParam('form')->getServiceManager()->get('doctrine.entitymanager.orm_default');
         $listRoles = $em->getRepository(Entity\Role::class)->findBy(array('id' => $post['roles']));
         $zfcUser->updateRoles($listRoles);
         $listGroup = $em->getRepository(Entity\Group::class)->findBy(array('id' => $post['groups']));
         $zfcUser->updateGroups($listGroup);
     });
 }
示例#10
0
 public function onBootstrap(MvcEvent $e)
 {
     $sm = $e->getApplication()->getServiceManager();
     /* @var $eventManager \Zend\EventManager\EventManager */
     $eventManager = $e->getApplication()->getEventManager();
     $eventManager->attach($sm->get('Authorize\\Guard\\Controller'));
     $eventManager->attach($sm->get('Authorize\\View\\UnauthorizedStrategy'));
     /* @var $acl \Authorize\Permission\Acl */
     $acl = $sm->get('Authorize\\Permission\\Acl');
     /* @var $serviceUser \User\Service\User */
     $serviceUser = $sm->get('User\\Service\\User');
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\Navigation\Page\Mvc::setDefaultRouter($sm->get('router'));
 }
示例#11
0
 public function onBootstrap($e)
 {
     $app = $e->getApplication();
     $em = $app->getEventManager();
     $sm = $app->getServiceManager();
     $list = $this->whitelist;
     $auth = $sm->get('zfcuser_auth_service');
     # global check access
     $em->attach(MvcEvent::EVENT_ROUTE, function ($e) use($list, $auth) {
         $match = $e->getRouteMatch();
         # No route match, this is a 404
         if (!$match instanceof RouteMatch) {
             return;
         }
         # Route is whitelisted
         $name = $match->getMatchedRouteName();
         if (in_array($name, $list)) {
             return;
         }
         # User is authenticated
         if ($auth->hasIdentity()) {
             return;
         }
         # Redirect to the user login page
         $router = $e->getRouter();
         $url = $router->assemble(array(), array('name' => 'zfcuser/login'));
         $response = $e->getResponse();
         $response->getHeaders()->addHeaderLine('Location', $url);
         $response->setStatusCode(302);
         return $response;
     }, -100);
     # if not auth change Template
     if (!$auth->hasIdentity()) {
         $em->attach(MvcEvent::EVENT_ROUTE, function ($e) {
             $vm = $e->getViewModel();
             $vm->setTemplate('layout/blank');
         });
     }
     # Add ACL information to the Navigation view helper
     $authorize = $sm->get('BjyAuthorizeServiceAuthorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     Navigation::setDefaultAcl($acl);
     Navigation::setDefaultRole($role);
 }
示例#12
0
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $adapter = $e->getApplication()->getServiceManager()->get('Zend\\Db\\Adapter\\Adapter');
     $sm = $e->getApplication()->getServiceManager();
     $config = $e->getApplication()->getServiceManager()->get('Configuration');
     $settings = $e->getApplication()->getServiceManager()->get('SettingsService');
     $eventManager->attach(new UserRegisterListener($adapter));
     $eventManager->attach(new LogListener());
     // Add ACL information to the Navigation view helper
     $authorize = $e->getApplication()->getServiceManager()->get('BjyAuthorize\\Service\\Authorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     // translating system
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     $session = new Container('base');
     // Get the visitor language selection
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     $locale = $session->offsetGet('locale');
     // Get the locale
     if (empty($locale)) {
         $locale = \Locale::getPrimaryLanguage(\Locale::getDefault());
         // Get the locale
     }
     if (!empty($locale) && 2 == strlen($locale)) {
         $locale .= "_" . strtoupper($locale);
     }
     $translator->setLocale($locale)->setFallbackLocale('en_US');
     $isCompress = $settings->getValueByParameter('Base', 'iscompressed');
     if ($isCompress) {
         $eventManager->getSharedManager()->attach('Zend\\Mvc\\Application', 'finish', array($this, 'compressHtml'), 1002);
     }
 }
示例#13
0
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     /* Translator */
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     $translator->addTranslationFile('phpArray', './vendor/zendframework/zend-i18n-resources/languages/pt_BR/Zend_Validate.php', 'default', 'pt_BR');
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
     /* Injeta o ACL e o usuário no Navigator */
     $auth = $e->getApplication()->getServiceManager()->get('Admin\\Service\\Auth');
     $acl = $auth->getAcl();
     $role = $auth->getRole();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     // Remove itens do menu
     if ($role == 'admin') {
         $container = $e->getApplication()->getServiceManager()->get('navigation');
         $home = $container->findBy('route', 'home');
         $entrar = $container->findBy('uri', '/admin/auth');
         $container->removePage($home);
         $container->removePage($entrar);
     }
 }
示例#14
0
 public function __call($method, array $arguments = array())
 {
     return parent::__call($method, $arguments);
     // TODO: Change the autogenerated stub
 }
 private function createHelper(ServiceLocatorInterface $serviceLocator)
 {
     $helper = new NavigationHelper();
     $helper->setServiceLocator($serviceLocator);
     return $helper;
 }
示例#16
0
 /**
  * Set navigation data container
  *
  * Register default router and RouteMatch to MvcPage
  *
  * @param Container $container
  * @return self
  */
 public function setContainer($container = null)
 {
     //  Sets the default router for MVC pages
     $router = Pi::engine()->application()->getRouter();
     MvcPage::setDefaultRouter($router);
     //$routeMatch = Pi::engine()->application()->getRouteMatch();
     //MvcPage::setDefaultRouteMatch($routeMatch);
     if (is_array($container)) {
         $container = new Container($container);
     }
     parent::setContainer($container);
     return $this;
 }
示例#17
0
 /**
  * @group #3859
  */
 public function testMultipleNavigationsWithSameHelperAndSameContainer()
 {
     $sm = new ServiceManager();
     $nav1 = new Container();
     $sm->setService('nav1', $nav1);
     $helper = new Navigation();
     $helper->setServiceLocator($sm);
     // Test
     $menu = $helper('nav1')->menu();
     $actual = spl_object_hash($nav1);
     $expected = spl_object_hash($menu->getContainer());
     $this->assertEquals($expected, $actual);
     $menu = $helper('nav1')->menu();
     $expected = spl_object_hash($menu->getContainer());
     $this->assertEquals($expected, $actual);
     $menu = $helper()->menu();
     $expected = spl_object_hash($menu->getContainer());
     $this->assertEquals($expected, $actual);
 }
示例#18
0
 /**
  * @param AbstractPage[] $container
  * @param NavigationHelper $navigation
  *
  * @return string
  */
 protected function drawBootstrapNavigationProfile($container, $navigation)
 {
     switch ($this->level) {
         case 0:
             $navigationClass = 'nav navbar-nav navbar-right navbar-profile';
             $template = "<ul class='{$navigationClass}'>";
             break;
         default:
             $navigationClass = 'dropdown-menu';
             $template = "<ul class='{$navigationClass}'>";
             $template .= "<li class='navigation-li-username visible-sm-block visible-md-block visible-lg-block'>{$this->userName}</li>";
             $template .= "<li class='divider'></li>";
     }
     foreach ($container as $page) {
         if (!$page->isVisible() || !$navigation->accept($page)) {
             continue;
         }
         $hasChildren = $page->hasPages();
         // Add Navigation Headings
         if ($this->checkForHeading($page->getLabel(), $template)) {
             continue;
         }
         // Add Navigation Separators
         if ($this->checkForSeparator($page->getLabel(), $template)) {
             continue;
         }
         $this->userName = $page->getLabel();
         $liParams = $this->level ? '' : " id='fat-menu' class='dropdown profile-menu'";
         $aParams = $this->level ? '' : " id='drop-profile' class='dropdown-toggle profile-menu-cover' data-toggle='dropdown'";
         $additional = $this->level ? '' : "<img class='navigation-avatar' src='{$page->get('icon')}'> <span class='visible-xs-inline-block navigation-xs-username'>{$this->userName}</span>";
         if (!$hasChildren) {
             if ($page->getLabel() == 'lampushka') {
                 $template .= "<li{$liParams}><a tabindex='-1' href='#'{$aParams} id='submit-idea'>Give Feedback <span class='submit-idea-icon'></span></a></li>";
             } elseif ($page->getLabel() == 'Lunchroom') {
                 $venueService = $this->serviceManager->getServiceLocator()->get('service_venue_venue');
                 if ($venueService->thereIsLunchroomInUserCityThatExceptOrders()) {
                     $template .= "<li{$liParams}><a tabindex='-1' href='{$page->getHref()}'{$aParams}>{$page->getLabel()}</a></li>";
                 }
             } else {
                 $template .= "<li{$liParams}><a tabindex='-1' href='{$page->getHref()}'{$aParams}>{$page->getLabel()}</a></li>";
             }
         } else {
             $template .= "<li{$liParams}><a tabindex='-1' href='#'{$aParams}>{$additional}</a>";
             $this->level++;
             $template .= $this->drawBootstrapNavigationProfile($page->getPages(), $navigation);
             $this->level--;
             $template .= '</li>';
         }
     }
     $template .= '</ul>';
     return $template;
 }
示例#19
0
 /**
  * 
  * @param MvcEvent $e
  */
 public function onRender(MvcEvent $e)
 {
     Navigation::setDefaultAcl($e->getApplication()->getServiceManager()->get('Acl'));
     Navigation::setDefaultRole($this->getRole($e));
 }
 /**
  * Create and return a navigation helper instance. (v3)
  *
  * @param ContainerInterface $container
  * @param string $requestedName
  * @param null|array $options
  * @return NavigationHelper
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $helper = new NavigationHelper();
     $helper->setServiceLocator($this->getApplicationServicesFromContainer($container));
     return $helper;
 }
示例#21
0
文件: Module.php 项目: odegroot/ers
 public function onBootstrap($e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $eventManager->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) {
         $controller = $e->getTarget();
         $controllerClass = get_class($controller);
         $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
         $config = $e->getApplication()->getServiceManager()->get('config');
         if (isset($config['module_layouts'][$moduleNamespace])) {
             $controller->layout($config['module_layouts'][$moduleNamespace]);
         }
     }, 100);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $this->bootstrapSession($e);
     $application = $e->getApplication();
     $sm = $application->getServiceManager();
     #$sm   = $e->getApplication()->getServiceManager();
     $auth = $sm->get('BjyAuthorize\\Service\\Authorize');
     if (!\Zend\Console\Console::isConsole()) {
         $acl = $auth->getAcl();
         $role = $auth->getIdentity();
         \Zend\View\Helper\Navigation::setDefaultAcl($acl);
         \Zend\View\Helper\Navigation::setDefaultRole($role);
     }
     $sharedManager = $application->getEventManager()->getSharedManager();
     $sharedManager->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) use($sm) {
         if ($e->getParam('exception')) {
             $sm->get('Logger')->crit($e->getParam('exception'));
             $auth = $sm->get('zfcuser_auth_service');
             if (!$auth->hasIdentity()) {
                 $url = $e->getRouter()->assemble(array(), array('name' => 'zfcuser/login'));
                 $response = $e->getResponse();
                 $response->getHeaders()->addHeaderLine('Location', $url);
                 $response->setStatusCode(302);
                 $response->sendHeaders();
                 // When an MvcEvent Listener returns a Response object,
                 // It automatically short-circuit the Application running
                 // -> true only for Route Event propagation see Zend\Mvc\Application::run
                 // To avoid additional processing
                 // we can attach a listener for Event Route with a high priority
                 $stopCallBack = function ($event) use($response) {
                     $event->stopPropagation();
                     return $response;
                 };
                 //Attach the "break" as a listener with a high priority
                 $e->getApplication()->getEventManager()->attach(MvcEvent::EVENT_ROUTE, $stopCallBack, -10000);
                 return $response;
             }
             $emailService = $sm->get('ErsBase\\Service\\EmailService');
             $emailService->sendExceptionEmail($e->getParam('exception'));
         }
     });
     $zfcAuthEvents = $sm->get('ZfcUser\\Authentication\\Adapter\\AdapterChain')->getEventManager();
     $zfcAuthEvents->attach('authenticate.success', function ($authEvent) use($sm) {
         $loginService = $sm->get('PreReg\\Service\\LoginService');
         $user_id = $authEvent->getIdentity();
         $loginService->setUserId($user_id);
         $loginService->onLogin();
         error_log('this is on the login');
         return true;
     });
     $zfcAuthEvents->attach('logout', function ($authEvent) use($sm) {
         $loginService = $sm->get('PreReg\\Service\\LoginService');
         #$user_id = $authEvent->getIdentity();
         #$loginService->setUserId($user_id);
         $loginService->onLogout();
         return true;
     });
 }