O'Reilly logo

CakePHP 2 Application Cookbook by Jorge González, James Watts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listeners and subscribers

Listeners in the framework implement the observer pattern, as described at http://en.wikipedia.org/wiki/Observer_pattern. A listener object waits to be notified of a new event. If notified, it will then check if the event can be handled, and if so, it will run the event-handling method based on the event name.

In CakePHP, anything can be a listener; the only requirement is to implement the CakeEventListener interface and provide a public implementedEvents() method, which returns the names of the exposed events with their respective methods to process the event.

If you have significant processing logic in your event listeners for a live service, consider using a job queue. Refer to the Event stacking recipe later in this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required