How we can use the Symfony2 Event Dispatcher component to enable e-commerce in our existing application, for a range of product types.
There are many e-commerce solutions out there, which can provide us with fully featured online shops. However, if you already have an existing website or application, especially one that needs to deal with more than typical e-commerce products, then some of these solutions can be more trouble than they are worth.
Let’s say we have an existing event booking website; it has all the functionality we need to create and publicise events, and users can sign-up to events. The only thing missing is that up until now it has only supported registering for events; there is no notion of paying for an event. We don’t want to have to rewrite our booking engine to be based around the notion of products, and we also might want to support turning other things into purchasable entities, perhaps charging for users to create their own events.
The Observer pattern, and how it can help us
The Observer design pattern allows an object to maintain a list of its dependant objects, and can automatically notify them of changes to the object, so that it can take appropriate action.
THIS IS A PREVIEW. DOWNLOAD APRIL 2013’S ISSUE TO READ THE FULL ARTICLE.