Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Add auto escape method to Zend\View\Helper\FlashMessenger #5743

Merged
merged 7 commits into from
Apr 11, 2014

Conversation

Martin-P
Copy link
Contributor

Added methods setAutoEscape and getAutoEscape to Zend\View\Helper\FlashMessenger as proposed in issue #5600.

@mwillbanks
Copy link
Contributor

I think this should also be defined out on the render portion of the object so that you can set it easily within one line or rather than using an initializer.

@Martin-P
Copy link
Contributor Author

Martin-P commented Mar 3, 2014

What exactly do you mean? As a third parameter for the method render()? You don't need an initializer to set the auto escape, you can do this when calling the view helper:

echo $this->flashMessenger()->setAutoEscape(false)->render();

@mwillbanks
Copy link
Contributor

@Martin-P yes; understand that. but many people like to utilize it as follows:

echo $this->flashMessenger()->render('MyNamespace', array('alert alert-success'));

I am ultimately saying that one might want to leverage a boolean flag as the third option.

@weierophinney
Copy link
Member

Agreed with @mwillbanks -- escaping is a rendering issue, and it should be possible to pass the flag to render(). The workflow would be as follows:

  • User can write a factory to set it via setter: $flash->setAutoEscape(true)
  • User can set the flag in a view script (or elsewhere): $flash->setAutoEscape(true)
  • User can set the flag for the current invocation only: $flash('MyNamespace', array('alert'), true) - In this case, if the flag is null, the value of the $autoEscape property is used.

Make sense, @Martin-P ?

@Martin-P
Copy link
Contributor Author

Martin-P commented Mar 5, 2014

Thanks for the clarification, I updated the code accordingly.

@Ocramius Ocramius added the View label Apr 3, 2014
@Ocramius
Copy link
Member

Ocramius commented Apr 3, 2014

This PR needs a rebase

@weierophinney weierophinney added this to the 2.4.0 milestone Apr 11, 2014
@weierophinney weierophinney self-assigned this Apr 11, 2014
weierophinney added a commit that referenced this pull request Apr 11, 2014
Add auto escape method to Zend\View\Helper\FlashMessenger
weierophinney added a commit that referenced this pull request Apr 11, 2014
- use `null ===` instead of `is_null` (consistency)
weierophinney added a commit that referenced this pull request Apr 11, 2014
- Return from conditional, to remove an else clause
weierophinney added a commit that referenced this pull request Apr 11, 2014
@weierophinney weierophinney merged commit 56bb2fa into zendframework:develop Apr 11, 2014
wdalmut pushed a commit to wdalmut/zf2 that referenced this pull request Apr 24, 2014
- use `null ===` instead of `is_null` (consistency)
wdalmut pushed a commit to wdalmut/zf2 that referenced this pull request Apr 24, 2014
- Return from conditional, to remove an else clause
wdalmut pushed a commit to wdalmut/zf2 that referenced this pull request Apr 24, 2014
- use `null ===` instead of `is_null` (consistency)
wdalmut pushed a commit to wdalmut/zf2 that referenced this pull request Apr 24, 2014
- Return from conditional, to remove an else clause
@Martin-P Martin-P deleted the issue-5600 branch August 13, 2014 14:06
freax pushed a commit to freax/zf2 that referenced this pull request Nov 27, 2014
- use `null ===` instead of `is_null` (consistency)
freax pushed a commit to freax/zf2 that referenced this pull request Nov 27, 2014
- Return from conditional, to remove an else clause
@rodrigotavio91
Copy link

I'm trying to put a link into a flashmessage... this working? Cause in my project, this function don't have this parameter $autoEscape.

I'm sorry, just now I saw that it will be available in ZF 2.4.0.

weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015
…ue-5600

Add auto escape method to Zend\View\Helper\FlashMessenger
weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015
- use `null ===` instead of `is_null` (consistency)
weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015
- Return from conditional, to remove an else clause
weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants