I'd like to pick up this topic again.
Even though I didn't really understand the PHP problem that still persists in 
PHP 5.2.1(*), I found my own workaround.

(*) Notice: Indirect modification of overloaded property 
Zend_Session_Namespace::$default has no effect in Ralph_FlashMessage.php on 
line 89

Here's my diff to Ralph's 
http://svn.ralphschindler.com/repo/ZendFramework/library/FlashMessage.php:

-----------------------------
# diff Ralph_FlashMessage.php FlashMessage.php
51c51
<             self::$_session = new Zend_Session(__CLASS__);
---
>             self::$_session = new Zend_Session_Namespace(__CLASS__);
84c84,86
<             self::$_session->{$namespace} = array();
---
>             $messages = array();
>         } else {
>             $messages = self::$_session->{$namespace};
85a88
>         $messages[] = $message;
87c90
<         self::$_session->{$namespace}[] = $message;
---
>         self::$_session->{$namespace} = $messages;
-----------------------------

Tested on PHP 5.2.1 & latest ZF svn revision.
It may be an ugly workaround to use a local temp variable $messages inside the 
addMessage method, but like this it works wonderful. Let me know if I'm missing 
something here in this rather complex implementation of a simple thing.

Cheers,
Philip


Ralph Schindler wrote:
> Right, the Zend_Session API has changed very significantly yesterday,
> and we are in the stages of finializing the would be ZF 1.0 Zend_Session
> api.  I will update FlashMessage to work with whats currently in svn,
> but do know that it could change only slightly more since we are in the
> finializing stages.. and there is one decision to make and is open to
> the community for comments.
> 
> -ralph
> 
> Christian Wittwer wrote:
>>> http://svn.ralphschindler.com/repo/ZendFramework/library/
>>>
>>> It currently uses Zend_Session, also implementing countable,
>>> iteratable interface.  I use it to add messages in my controllers,
>>> and also to retrieve messages in my view scripts.
>>>
>>> FlashMessage::add($message);
>>>
>>> if (FlashMessage::hasMessages()) {
>>>     $messages = FlashMessage::getMessages();
>>>     foreach ($messages as $message) { echo $message; }
>>> }
>>>
>>> It also supports namespacing so that multiple components can use
>>> FlashMessage and keep their messages separated, this is good if you
>>> know certain (named) messages will have to be directed to a specific
>>> part of the view.
>>
>> Hi Ralph,
>> Your FlashMessage Class don't work with the latest svn revision (3290).
>>
>> Fatal error: Call to private Zend_Session::__construct() from context
>> 'FlashMessage'
>>
>> Chris
>>
>>
> 

Reply via email to