/**
  * Outputs message depending on flag
  *
  * @return string
  */
 public function render()
 {
     // get messages
     $allMessages = ['danger' => array_unique(array_merge($this->flashMessenger->getErrorMessages(), $this->flashMessenger->getCurrentErrorMessages())), 'success' => array_unique(array_merge($this->flashMessenger->getSuccessMessages(), $this->flashMessenger->getCurrentSuccessMessages())), 'warning' => array_unique(array_merge($this->flashMessenger->getWarningMessages(), $this->flashMessenger->getCurrentWarningMessages())), 'info' => array_unique(array_merge($this->flashMessenger->getInfoMessages(), $this->flashMessenger->getCurrentInfoMessages())), 'default' => array_unique(array_merge($this->flashMessenger->getMessages(), $this->flashMessenger->getCurrentMessages()))];
     // clear messages
     $this->flashMessenger->clearMessagesFromContainer();
     $this->flashMessenger->clearCurrentMessagesFromContainer();
     // initialize output
     $output = '';
     // loop through messages
     foreach ($allMessages as $groupKey => $groupMessages) {
         foreach ($groupMessages as $message) {
             $addClass = $groupKey == 'default' ? '' : 'alert-' . $groupKey;
             // setup view model
             $viewModel = new ViewModel();
             $viewModel->setVariable('alertClass', $addClass);
             $viewModel->setVariable('alertMessage', $message);
             $viewModel->setTemplate('zf2rapid-library/widget/bootstrap-alert');
             // add rendered output
             $output .= $this->getView()->render($viewModel);
         }
     }
     // return output
     return $output . "\n";
 }
Esempio n. 2
0
 /**
  * Outputs message depending on flag
  *
  * @return string 
  */
 public function __invoke()
 {
     // get messages
     $messages = array_unique(array_merge($this->flashMessenger->getMessages(), $this->flashMessenger->getCurrentMessages()));
     $warning_messages = array_unique(array_merge($this->flashMessenger->getWarningMessages(), $this->flashMessenger->getCurrentWarningMessages()));
     $error_messages = array_unique(array_merge($this->flashMessenger->getErrorMessages(), $this->flashMessenger->getCurrentErrorMessages()));
     $success_messages = array_unique(array_merge($this->flashMessenger->getSuccessMessages(), $this->flashMessenger->getCurrentSuccessMessages()));
     $this->flashMessenger->getSuccessMessages();
     // initialize output
     $output = '';
     // loop through messages
     foreach ($messages as $message) {
         // create output
         $output .= '<div class="alert" role="alert">';
         $output .= $message;
         $output .= '</div>';
     }
     foreach ($error_messages as $error_message) {
         // create output
         $output .= '<div class="alert alert-danger" role="alert">';
         $output .= $error_message;
         $output .= '</div>';
     }
     foreach ($warning_messages as $warning_message) {
         // create output
         $output .= '<div class="alert alert-warning" role="alert">';
         $output .= $warning_message;
         $output .= '</div>';
     }
     foreach ($success_messages as $success_message) {
         // create output
         $output .= '<div class="alert alert-success" role="alert">';
         $output .= $success_message;
         $output .= '</div>';
     }
     // clear messages
     $this->flashMessenger->clearMessages();
     $this->flashMessenger->clearCurrentMessages();
     // return output
     return $output . "\n";
 }
Esempio n. 3
0
 /**
  * @param bool $admin
  * @param bool $current
  * @return string
  */
 public function __invoke($admin = false, $current = false)
 {
     $prefix = $this->getHTMLPrefix($admin);
     $html = '';
     $flashMessenger = new FlashMessenger();
     foreach ($current ? $flashMessenger->getCurrentErrorMessages() : $flashMessenger->getErrorMessages() as $message) {
         $html .= $admin ? $this->renderAdminMessage($message, 'alert-error') : $this->renderAppMessage($message);
     }
     foreach ($current ? $flashMessenger->getCurrentSuccessMessages() : $flashMessenger->getSuccessMessages() as $message) {
         $html .= $admin ? $this->renderAdminMessage($message, 'alert-success') : $this->renderAppMessage($message);
     }
     foreach ($current ? $flashMessenger->getCurrentMessages() : $flashMessenger->getMessages() as $message) {
         $html .= $admin ? $this->renderAdminMessage($message, 'alert-info') : $this->renderAppMessage($message);
     }
     $postfix = $this->getHTMLPostfix($admin);
     return !empty($html) ? $prefix . $html . $postfix : '';
 }