Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

3 participants

@mwillbanks
Collaborator

Overview

Flash Messenger view helper is broken for less than PHP 5.4; this is due to the use of a closure and utilize the variable $this. The fix for that was to ensure that we could just use the variables.

Secondly when one attempts the utilize the view helper using the defaults much like you add a message inside of the controller

$this->plugin('flashMessenger')->addMessage('foo');

Then you should be able to get that value similarly in the view like:

$this->plugin('flashMessenger')->render();
@blanchonvincent

@mwillbanks Default namespace with the with helper is cool, thx !

Thank you for the fix, @rwellens don't forget php 5.3 :)

@weierophinney weierophinney merged commit bb8c869 into zendframework:develop

1 check failed

Details default The Travis build failed
@mwillbanks mwillbanks deleted the mwillbanks:hotfix/flash-messenger-default-render-botched branch
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3566' into develop
Close #3566
a0193bf
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-view
@weierophinney weierophinney Merge branch 'hotfix/3566' into develop 2adfd5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 25, 2013
  1. @mwillbanks

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

    mwillbanks authored
    …when calling $this->flashMessenger()->render()
This page is out of date. Refresh to see the latest.
View
18 library/Zend/View/Helper/FlashMessenger.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);
View
10 tests/ZendTest/View/Helper/FlashMessengerTest.php
@@ -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;
Something went wrong with that request. Please try again.