phpdoctrinelistenerbehavior

How to override preUpdate action to not modify my `updated_at` field in Doctrine?


I want to disable the automatic behaviour of changing the 'updated_at' field when an object is updated. I want to do it manually; or at least, have the posibility to disable it as wanted.

I know I can do this by building my own behaviour as in this great answer. But I was searching for something 'cleaner' modifying a listener of the object.

--

Doctrine::getTable('Place')->getRecordListener()->setOption('disabled', true);
// or
Doctrine::getTable('Place')->getRecordListener()->setOption('disabled', array('preUpdate'));
// As reference, I've used these two lines on a Symfony Task

Any more ideas, or code to look at?


Solution

  • according to the docs at http://www.doctrine-project.org/documentation/manual/1_1/nl/behaviors:core-behaviors#timestampable if you want to use Timestampable but not the updated portion of it just use:

    Timestampable:
      updated:
        disabled: true
    

    And add in your own updated_at field in the columns section.