On 6/3/08, Jeffrey Sambells <[EMAIL PROTECTED]> wrote:
>
> Wouldn't it be better to provide a method to retrieve the messages
> regardless of which page load it is in so that the flashMessanger could be
> the generic message container for either case?
Exactly!
However, while I've read through the source in the past, I don't know why
I've never noticed getCurrentMessages(). That should solve my problem for
now, thanks!
For example, if I do:
>
> $this->_flashMessenger->addMessage('My Message');
> $messages = $this->_flashMessenger->getMessages();
>
> I would assume that $message should contain 'My Message' since I just added
> it in the previous line, but it doesn't. The addMessage() method stores the
> message in the session, while getMessage() retrieves from the $_message
> property of the object. The $_message property is populated only from the
> previous request but not updated when new messages are added.
>
> In some cases the part of the application that needs to indicate a message
> won't know yet if the page will re-direct or not at the end so it seems
> silly to use two different models for the basically the same purpose
> (message storage). Could the flashMessanger provide a getAllMessages()
> method that would remove like messages from the session if they're retrieved
> on the same call so you get all message without repeating them in the next
> request?
>
> I guess this could be accomplished by manually merging getMessages() and
> getCurrentMessages() but then you have to manually clear the current
> messages too which is something else to remember. It would be nice to have
> something like this in the FlashMessenger:
>
> function getAllMessages( $clear = true ) {
> $all = array_merge( $this->getMessages(),
> $this->getCurrentMessages() );
> if ( true === $clear) {
> $this->clearMessages();
> }
> return $all;
> }
>
> - Jeff
>
>
--
Vincent