Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jan 26, 2013
Jump to file or symbol
Failed to load files and symbols.
+22 −6
Split
@@ -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;