0

Is there a quick way to add a Doctrine event listener to all tables in a Symfony 1.4 project?

I've tried adding this to the Doctrine_Manager in ProjectConfiguration::configureDoctrine() but this doesn't seem to get called. DQL callbacks are enabled, and regular behaviours seem to work - I just can't seem to attached my listener properly.

I'm extending the Doctrine_Record_Listened like so:

<?php class siteFilterListener extends Doctrine_Record_Listener { ... }
j0k
  • 22,600
  • 28
  • 79
  • 90
Steve Browett
  • 115
  • 1
  • 5
  • Can you give a bit more information: What do you want to bind to, what do you want to achieve, how are you adding your events to doctrine, and in what way does doctrine different from what you expect it to do? – Arend Jul 15 '12 at 20:50

1 Answers1

0

The best way to achieve (whatever you are trying to) is to create a behaviour which has a listener and add that behaviour to each of your doctrine table. Enable callbacks, and your listener will be called for the events you've overridden: insert, delete, postsave, postdql.

I would suggest you use any behaviour plugin as your base, and start making changes. I have written 4 very simple behaviours, each with just 2 code files - that can be a good starting point for you.

http://www.symfony-project.org/plugins/developer/prasad-gupte

Prasad
  • 1,822
  • 3
  • 23
  • 40