I'm starting to try to wrap my head around using Doctrine listeners in the context of a symfony application, and I'm encountering some confusion that I was hoping someone out there might be able to help me clear up.
The rough outline of what I'm trying to accomplish is this: the site in question has a frontend and an admin console. The frontend is read-only, and I am caching some data using APC. I want to modify the admin console so that any time a change is made, the APC cache is cleared. The code for clearing the cache is working fine... what I'm struggling with is the most efficient place to put it so that it automatically happens for all database changes made via the admin console. I was hoping that I could accomplish this with a listener so that the cache clearing code was in one central place. So, here's what I'm doing: 1. In the configuration for the admin console, I have this: public function initialize() { $manager = Doctrine_Manager::getInstance(); $manager->setAttribute('use_dql_callbacks', true); $manager->addRecordListener(new ClearCacheListener()); } 2. ClearCacheListener looks like this: class ClearCacheListener extends Doctrine_Record_Listener { public function postSave(Doctrine_Event $event) { $this->clearCache($event); } // followed by identical implementations of preDqlDelete, postDelete, preDqlUpdate, postUpdate, postInsert, as well as the clearCache method } The admin console is using the sf 1.2 admin generator so it makes use of the form framework, etc. I can see that the listener has been registered and is kind of working, because the preDqlDelete hook gets executed whenever I directly delete something using DQL. However, the other hooks don't seem to fire. Am I misunderstanding what it means to attach a listener to the manager? I thought that the listener would fire for matching events on any model. Thanks for any clarification on this issue. I'm looking forward to mastering listeners as I can see that they will be incredibly handy. David Brewer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---