News Feed
Jobs Feed
Sections




News Archive
feed this:

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

Kevin Schroeder's Blog:
A little more advanced ZF2 EventManager usage
April 24, 2012 @ 08:54:55

Kevin Schroeder has a new post to his his blog with a bit more advanced example of using the Zend Framework 2 EventManager to make global event triggers.

If you look at my previous post on the ZF2 EventManager class you might be tempted to think that you are limited only to listening to events for local instances of the event manager. But no, my friend, you would be wrong. The event manager actually provides access to a sort of global event manager. But it's more than that. This global event manager allows you to listen in on events for various targets.

He includes an example of how to use the EventManager in a specific namespace that's triggered based on a custom event. He attaches a custom class, "cls2", to a listener on his "ns1/cls1" class.

0 comments voice your opinion now!
zendframework2 eventmanager example tutorial global


Rob Allen's Blog:
An introduction to ZendEventManager
April 23, 2012 @ 09:29:08

Rob Allen has a new post to his blog today introducing you to the ZendEventManager component of the Zend Framework v2, a key part of how this latest version of the framework does its job.

Zend Framework 2's EventManager is a key component of the framework which is used for the core MVC system. The EventManager allows a class to publish events that other objects can listen for and then act when the event occurs. The convention within Zend Framework 2 is that any class that triggers events composing its own EventManager.

He starts with some terminology to get everyone on the same page (listener, event, EventManager) and includes an example of its use in setting up a "PhotoMapper" object showing how to trigger events in the "findById" method. He shows how to listen for a specific event (in his case, a "pre-execute" on the "findById" method) and a method for "short circuiting" the listener based on the response from the "trigger" call. He also touches on the "SharedEventManager" that can be used to add an event across all of your application at the same time.

0 comments voice your opinion now!
introduction zendframework eventmanager trigger event


Rob Allen's Blog:
A list of ZF2 Events
March 16, 2012 @ 09:49:15

In a reference sort of post, Rob Allen has listed out the events that are provided in the Zend Framework 2 "Application" functionality.

Both the Module Manager and the MVC system use the Event Manger extensively in order to provide "hook points" for you to add your own code into the application flow. This is a list of the events triggered by each class during a standard request with the Skeleton Application.

It's broken up into the three main chunks - Module Manager, Bootstrap and Application - with any sub-requests and their sources (like "render", "dispatch" or "response"). You can find out more about ZF2's Event Manager in other posts like this one from Kevin Schroeder or this from Matthew Weier O'Phinney.

0 comments voice your opinion now!
zendframework2 events eventmanager source


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


Kevin Schroeder's Blog:
Zend Framework 2 Event Manager
September 16, 2011 @ 11:40:47

Kevin Schroeder has a new post today sharing some of his experience with the Zend Framework 2 Event Manager in a simple example of pre- and post-validation hooks in a model.

I got to play with the Event Manager. I did like the plugin functionality in ZF1, but it required some pretty static coding. In some cases, like the front controller plugins, it makes more sense (though this way seems more desirable). [...] It's a ZF1 application, but since (it seems) the event manager is self-contained (and the autoloader works with both ZF1 and ZF2) you can simply paste it into your include_path and BOOM, you have an event manager.

In his case he has a set of models extending a base class and wanted to introduce pre- and post-validation hooks to make it simpler to check the data he was working with. He includes the code for his base model class showing how he implemented the ZF2 EventManager in his ZF1 application. He attaches an event to the password class property and, on update, it automatically updates a temporary password value too.

You can get more information on using the EventManager in this other post from Matthew Weier O'Phinney.

0 comments voice your opinion now!
eventmanager zendframework tutorial validation hook


Matthew Weier O'Phinney's Blog:
Using the ZF2 EventManager
September 13, 2011 @ 09:25:32

Matthew Weier O'Phinney, lead on the Zend Framework project, has a new post to his blog talking about the event manager in the Zend Framework, v2 and how to use it in a refectored version of a previous post.

Earlier this year, I wrote about Aspects, Intercepting Filters, Signal Slots, and Events, in order to compare these similar approaches to handling both asychronous programming as well as handling cross-cutting application concerns in a cohesive way. I took the research I did for that article, and applied it to what was then a "SignalSlot" implementation within Zend Framework 2, and refactored that work into a new "EventManager" component. This article is intended to get you up and running with it.

You'll need to already have an install of the Zend Framework (v2) installed to follow along. He covers some of the basic terminology and the base code the rest of the tutorial's built from - a simple EventManager instance with a trigger on it. He moves on from there showing how to specify targets for the triggers, setting up global static listeners and listener aggregates as well as how to short circuit listener execution. He wraps up the post by applying all of the examples into one simple caching tool that responds to the trigger by either sending back a new instance or pulling the previously generated one from the cache.

0 comments voice your opinion now!
zendframework v2 eventmanager tutorial framework component



Community Events











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


framework unittest hhvm podcast security facebook hack package release application component install code overview opinion introduction symfony2 language composer example

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