The Artima Developer Community
Sponsored Link

PHP Buzz Forum
PEAR is getting event support

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Stephan Schmidt

Posts: 238
Nickname: schst
Registered: Sep, 2004

Stephan Schmidt is a founding member of PHP Application Tools and a PEAR developer.
PEAR is getting event support Posted: Jan 16, 2005 10:47 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Stephan Schmidt.
Original Post: PEAR is getting event support
Feed Title: a programmer's best friend
Feed URL: http://blog.php-tools.net/rss.php?version=1.0
Feed Description: The blog of PHP Application Tools
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Stephan Schmidt
Latest Posts From a programmer's best friend

Advertisement
Bertrand Mansion started a new proposal for Event_Dispatcher, a package that provides easy-to-use event handling for your projects. I only realized that this package has been proposed as Betrand started the call for votes on this package, but as I'm using this technique a lot in patPortal and at my work, I decided to give this package a try.

The package's architecture is quite simple: There is an Event_Dispatcher, which is able to hold observers (native PHP callbacks) for different notification types. These observers will be notified whenever an event (aka notification) occurs. This notification is a simple object that stores information about the event itself. In real life you can use it to add functionality to your sites, without having to change the code of your application, e.g. in my applications, I send a notification,whenever a user places an order (onOrder) and pass the order object to the notification. This way I can easily plug in new objects, that write logfiles, update cookies or send a trackback to an affiliate partner.

As I liked the simple architecture of the package, I played with it a little and reached some limits of the package as it has been missing features I heavily use in my commercial projects. Thi first feature I was missing was the ability to let an observer cancel the notification (for example if you want to plugin in some checks before a user is able to place an order, which enable you to cancel an order after the user pressed the submit button), so I added this to Bertrand's code.
Next was the ability for event bubbling, which allows you unlimited levels of event handling and an event that was triggered at a lower level will then inform all observers of the higher levels. So I added this feature as well, by allowing the user to nest as many dispatchers as they like.
And last but not least, I wanted to be able to use a custom class for notifications, which is now possible in my version as well (for a single dispatcher as well as all dispatchers).

I hope that Bertrand will include all these changes in the official distribution and that this package will be accepted by the PEAR community, so if you haven't voted, do it now.

Read: PEAR is getting event support

Topic: My Laptop : R.I.P. Previous Topic   Next Topic Topic: OOP and Performance

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use