2010年7月9日星期五

[fw-mvc] Using the objects implementing the Serializable Interface with Zend_Application

Hi all!

I have a cart application that uses the ideas found on Matthew Weier O'Phinney's blog found here: http://weierophinney.net/matthew/archives/202-Model-Infrastructure.html. It's a wonderfully written article (thanks Matthew!), and has helped me rethink how I conceptualize models and object aggregation in my applications.

When it came time to refactor my archaic shopping cart application, I decided to use some of those ideas, since they seemed to lend solve some design issues I was trying to resolve. Therefore I created a class designed as a data value object representing a discrete product (My_Model_Shop_Product) in the cart object. In addition, the object implements the Serializable Interface so that the session can be used as a container for cart data. Since the Product class must be loaded before the session is started, I have one require statement in index.php that loads the object before the application is bootstrapped. This solution doesn't seem "clean" to me, and whenever I look at the index file, the require statement seems incongruous. Of course, its commented so I know what is going on, but I would like to know if there is a more elegant solution to this situation.

I want to continue using the session as a container for cart data. I would prefer that the Product class be held in a Zend Application Resource, but these resources are called after Zend_Application sets up the session, so I am at a loss as to what to do. Or should I leave well enough alone? What would be the ZF way of doing this?

Any advice would greatly appreciated!

regards,

Nathan Garlington
www.tandrtrailer.com

没有评论: