Esempio n. 1
0
 public function onBootstrap(EventInterface $e)
 {
     // Récupération des erreurs en ajoutant un callback qui affiche l'erreur coté serveur
     $application = $e->getTarget();
     $event = $application->getEventManager();
     $event->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e) {
         error_log('DISPATCH_ERROR : ' . $e->getError());
         error_log($e->getControllerClass() . ' ' . $e->getController());
     });
     $event->attach(MvcEvent::EVENT_RENDER_ERROR, function (MvcEvent $e) {
         error_log('RENDER_ERROR : ' . $e->getError());
     });
     $event->attach(MvcEvent::EVENT_RENDER, function (MvcEvent $e) {
         $services = $e->getApplication()->getServiceManager();
         $session = $services->get('session');
         $rightViewModel = new ViewModel();
         if (!isset($session->user)) {
             $form = $services->get('MiniModule\\Form\\Authentification');
             $formUser = $services->get('MiniModule\\Form\\NewUser');
             $rightViewModel->setVariables(array('form' => $form, 'newUserForm' => $formUser));
             $rightViewModel->setTemplate('layout/form-auth');
         } else {
             $rightViewModel->setVariables(array('user' => $session->user));
             $rightViewModel->setTemplate('layout/info-auth');
         }
         $view = $e->getViewModel();
         // c'est le viewModel qui contient le layout (top viewModel)
         $view->addChild($rightViewModel, 'formulaireAuth');
     });
 }
Esempio n. 2
0
 public function onBootstrap(EventInterface $e)
 {
     // $e->getTarget() renvoit Zend\MVC\Application
     $application = $e->getTarget();
     // $sm = $application->getServiceManager();
     $event = $application->getEventManager();
     $event->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e) {
         error_log($e->getError());
         error_log($e->getControllerClass() . ' ' . $e->getController());
     });
 }
Esempio n. 3
0
 public function onBootstrap(EventInterface $e)
 {
     // Récupération des erreurs en ajoutant un callback qui affiche l'erreur coté serveur
     $application = $e->getTarget();
     $event = $application->getEventManager();
     $event->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e) {
         error_log('DISPATCH_ERROR : ' . $e->getError());
         error_log($e->getControllerClass() . ' ' . $e->getController());
     });
     $event->attach(MvcEvent::EVENT_RENDER_ERROR, function (MvcEvent $e) {
         error_log('RENDER_ERROR : ' . $e->getError());
     });
 }
Esempio n. 4
0
 public function onBootstrap(EventInterface $e)
 {
     // $e­>getTarget() renvoit Zend\MVC\Application
     //            $sm = $e->getTarget()->getServiceManager();
     //            $view = $sm->get('ViewManager');
     //            $resolv = new \Zend\View\Resolver\TemplateMapResolver(array(
     //                'error' => __DIR__ . '/view/error.phtml',
     //                'layout/layout' => __DIR__.'/view/layout.phtml',
     //                )
     //            );
     //            $view->getRenderer()->setResolver( $resolv );
     $application = $e->getTarget();
     $event = $application->getEventManager();
     $event->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e) {
         error_log('DISPATCH_ERROR : ' . $e->getError());
         error_log($e->getControllerClass() . ' ' . $e->getController());
     });
     $event->attach(MvcEvent::EVENT_RENDER_ERROR, function (MvcEvent $e) {
         error_log('RENDER_ERROR : ' . $e->getError());
     });
     $event->attach(MvcEvent::EVENT_RENDER, function (MvcEvent $e) {
         $services = $e->getApplication()->getServiceManager();
         //            $form = $services->get('MiniModule\Form\Authentification');
         $session = $services->get('session');
         $rightViewModel = new ViewModel();
         if (!isset($session->user)) {
             $form = $services->get('MiniModule\\Form\\Authentification');
             $formUser = $services->get('MiniModule\\Form\\NewUser');
             $rightViewModel->setVariables(array('form' => $form, 'newUserForm' => $formUser));
             $rightViewModel->setTemplate('layout/form-auth');
         } else {
             $rightViewModel->setVariables(array('user' => $session->user));
             $rightViewModel->setTemplate('layout/info-auth');
         }
         $view = $e->getViewModel();
         // c'est le viewModel qui contient le layout (top viewModel)
         //            $formViewManager = new ViewModel(array('form' => $form));
         //            $formViewManager->setTemplate('layout/form-auth');
         //            $view->addChild($formViewManager, 'formulaireAuth');
         $view->addChild($rightViewModel, 'formulaireAuth');
     });
 }