/**
  *
  * @return string
  */
 public function __invoke()
 {
     if ($this->request->getQuery('msg', false) && $this->flashMessenger->hasMessages()) {
         $messages = $this->flashMessenger->getMessages();
         foreach ($messages as $message) {
             $this->flashMessenger->addInfoMessage($message);
         }
     }
     $messageString = '';
     foreach ($this->namespaces as $class => $ns) {
         $this->flashMessenger->setNamespace($ns);
         $messages = $this->flashMessenger->getMessages();
         if ($this->flashMessenger->hasCurrentMessages()) {
             $messages += $this->flashMessenger->getCurrentMessages();
             $this->flashMessenger->clearCurrentMessages();
         }
         if (count($messages) > 0) {
             // Twitter bootstrap message box
             $messageString .= sprintf('<div class="container-fluid">
                     <div class="alert alert-%s alert-dismissable fade in">
                         <button data-dismiss="alert" class="close" aria-hidden="true" type="button">x</button>
                         %s
                     </div>
                 </div>', $class, implode('<br />', $messages));
         }
     }
     return $messageString;
 }
示例#2
0
 public function __invoke()
 {
     $messages = array();
     if ($this->flashMessenger->hasMessages()) {
         $messages['common'] = $this->flashMessenger->getMessages();
     }
     if ($this->flashMessenger->hasSuccessMessages()) {
         $messages['success'] = $this->flashMessenger->getSuccessMessages();
     }
     if ($this->flashMessenger->hasInfoMessages()) {
         $messages['info'] = $this->flashMessenger->getInfoMessages();
     }
     if ($this->flashMessenger->hasErrorMessages()) {
         $messages['danger'] = $this->flashMessenger->getErrorMessages();
     }
     if ($this->flashMessenger->hasWarningMessages()) {
         $messages['warning'] = $this->flashMessenger->getWarningMessages();
     }
     return $messages;
 }
示例#3
0
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $eventManager->attach(MvcEvent::EVENT_RENDER, function ($e) {
         $flashMessenger = new FlashMessenger();
         $messages = array_merge($flashMessenger->getSuccessMessages(), $flashMessenger->getInfoMessages(), $flashMessenger->getErrorMessages(), $flashMessenger->getMessages());
         if ($flashMessenger->hasMessages()) {
             $e->getViewModel()->setVariable('flashMessages', $messages);
         }
     });
     $eventManager->attach('route', array($this, 'onPreRoute'), 100);
     $moduleRouteListener->attach($eventManager);
 }