News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Robert Basic's Blog:
A Zend Framework 2 EventManager use case
October 20, 2011 @ 11:05:43

Robert Basic has a new post to his blog today with an use case for Zend Framework 2's event manager to solve a problem he has with "repetitive code" in some of his models.

Basically, this allows us to have one piece of code to trigger an event and to have one or more listeners listening to this event. When the event gets triggered, the listeners are called and then we can do *something*, like caching or logging. Logging or caching. [...] See, that's my problem. All the event examples stop at logging and caching. Truly there must be some other example for which this event stuff can be used for.

In his example code, he's used the EventManager in one of his models to add listeners to validate the post and "slugify" the post's title for use on the URL. You can find his code on github if you're interested in the full implementation.

0 comments voice your opinion now!
zendframework eventmanager usecase model listener save


blog comments powered by Disqus

Similar Posts

Till Klampaeckel's Blog: Iterating over a table (with Zend_Db_Table and Zend_Paginator)

Avnet Labs Blog: TDD with Zend Framework - testing controllers

Odafe Ojenikoh's Blog: Interactive PHP CLI Applications using Zend Form

PHPMaster.com: Build a CRUD App with Yii in Minutes

MaltBlue.com: Zend Framework 2 - Hydrators, Models and the TableGateway Pattern


Community Events





Don't see your event here?
Let us know!


install testing language list threedevsandamaybe interview developer symfony2 refactor introduction series podcast laravel configure framework release community code opinion unittest

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework