Last active
January 3, 2016 13:29
-
-
Save m4tm4t/8470086 to your computer and use it in GitHub Desktop.
Zend 2 crazy flash notices with namespaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set message | |
$this->flashMessenger() | |
->setNamespace("success") | |
->addMessage("You've been logged out"); | |
return $this->redirect()->toUrl('/'); | |
// Retrieve message | |
$notice = null; | |
$flash = $this->flashMessenger(); | |
$flash->setNamespace('success'); | |
if ($flash->hasMessages()) | |
$notice = array('type' => 'success', 'message' => $flash->getMessages()[0]); | |
$flash->setNamespace('error'); | |
if ($flash->hasMessages()) | |
$notice = array('type' => 'error', 'message' => $flash->getMessages()[0]); | |
$this->layout()->notice = $notice; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment