/** * * @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; }
public function seedMessages() { $helper = new FlashMessenger(); $helper->setSessionManager($this->session); $helper->addMessage('foo'); $helper->addMessage('bar'); $helper->addInfoMessage('bar-info'); $helper->addSuccessMessage('bar-success'); $helper->addErrorMessage('bar-error'); unset($helper); }