Permalink
Browse files

Flash Messenger fixes for PHP < 5.4, and fix for default namespacing …

…when calling $this->flashMessenger()->render()
  • Loading branch information...
1 parent 3466f7b commit bb8c869a345f186e7e6c9f53a35efe85573cdb67 @mwillbanks mwillbanks committed Jan 25, 2013
Showing with 22 additions and 6 deletions.
  1. +12 −6 library/Zend/View/Helper/FlashMessenger.php
  2. +10 −0 tests/ZendTest/View/Helper/FlashMessengerTest.php
@@ -83,11 +83,13 @@ public function __call($method, $argv)
}
/**
+ * Render Messages
*
- *
- * @param type $namespace
+ * @param string $namespace
+ * @param array $classes
+ * @return string
*/
- public function render($namespace = null, array $classes = array())
+ public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array())
{
$flashMessenger = $this->getPluginFlashMessenger();
$messages = $flashMessenger->getMessagesFromNamespace($namespace);
@@ -102,10 +104,14 @@ public function render($namespace = null, array $classes = array())
// Flatten message array
$escapeHtml = $this->getEscapeHtmlHelper();
$messagesToPrint = array();
- array_walk_recursive($messages, function($item) use (&$messagesToPrint, $escapeHtml) {
- if (($translator = $this->getTranslator()) !== null) {
+
+ $translator = $this->getTranslator();
+ $translatorTextDomain = $this->getTranslatorTextDomain();
+
+ array_walk_recursive($messages, function($item) use (&$messagesToPrint, $escapeHtml, $translator, $translatorTextDomain) {
+ if ($translator !== null) {
$item = $translator->translate(
- $item, $this->getTranslatorTextDomain()
+ $item, $translatorTextDomain
);
}
$messagesToPrint[] = $escapeHtml($item);
@@ -116,6 +116,16 @@ public function testCanDisplayListOfMessages()
$this->assertEquals($displayInfoAssertion, $displayInfo);
}
+ public function testCanDisplayListOfMessagesByDefaultParameters()
+ {
+ $helper = $this->helper;
+ $this->seedMessages();
+
+ $displayInfoAssertion = '<ul class="default"><li>foo</li><li>bar</li></ul>';
+ $displayInfo = $helper()->render();
+ $this->assertEquals($displayInfoAssertion, $displayInfo);
+ }
+
public function testCanDisplayListOfMessagesByInvoke()
{
$helper = $this->helper;

0 comments on commit bb8c869

Please sign in to comment.