Repository navigation
Conversation
| * | ||
| */ | ||
| public function getFlashAll($alt = array()) | ||
| { |
There was a problem hiding this comment.
Doesn't flash all means flash now + next ?
|
Fair point, @harikt. Perhaps the name is a little terse. |
3a638f7 to
743d5e2
Compare
|
Let's wait to hear from pmjones thoughts. |
743d5e2 to
cc0f489
Compare
- Segment::getFlashAll(); - Segment::getFlashNextAll();
cc0f489 to
5c7ca60
Compare
|
I added "add" methods here as well. @harikt, I just noticed that you said to wait on pmj, but i'm pretty sure you're right, so I had already gone and changed it. Obviously can always change to something else. As an illustration of my intended use case: <?php
// @codingStandardsIgnoreFile
abstract class MyAbstractResponder
{
protected $msgSegment = 'My\\Messages';
protected function addMessage($msg, $level = 'info')
{
$this->getSession()
->getSegment($this->msgSegment)
->addFlash(['lvl' => $level, 'msg' => $msg]);
}
protected function getMessages()
{
return $this->getSession()
->getSegment($this->msgSegment)
->getAllCurrentFlash([]);
}
protected function render()
{
$view = $this->getView();
$view->addData(['messages' => $this->getMessages()]);
$this->response->getBody()->write($view());
}
protected function updated()
{
$this->addMessage('Successfully updated thing', 'success');
$this->redirect();
}
//...
} |
|
@jakejohns Sorry that this is not merged. I am going to release a 4.x for session to make it compatible with 8.x . Newer feature is not incorported for now. So this is currently put on hold. |
Reading flash values required knowing their keys in advance, so rendering a list of flash messages meant reaching into $_SESSION directly. getSegment() already covers this for plain values; these two do the same for the current and the next request. Neither takes an alternative value, following getSegment() rather than the key-based getters: $alt exists to tell "key not set" apart from "key set to null", and an all-getter has no such ambiguity. Both return an empty array when nothing is set, so the result is always iterable. Proposed by Jake Johns in #47 and #52, and deferred because it changed a published interface.
|
Thanks for this, @jakejohns, and sorry it sat for so long. The "all getters" half has now shipped on $segment->getFlashAll(); // every flash value in the current request
$segment->getFlashNextAll(); // every flash value set for the next requestThe blocker you identified back in #47 — "the change in the interface is a Two deliberate differences from the patch here:
The Closing this one, since |
This is just #47 for 3.x.
It looks like there was already a
getAllequivalent:getSegment.