* status: new => closed
* resolution: => fixed
Old description:
> As discussed in the mailing-list, I attached a patch which adds a
> $_options class var + getter/setter method to the
> Doctrine_Record_Listener class, which would give us the opportunity to
> dis-/enable record listener at runtime.
>
> This solution is working if the Listener are checking their options array
> at the corresponding hooks like the bundled Timstampable listener and
> many others does.
>
> Example code to disable the timestampable (in this example the first
> attached listener) listener at runtime with the applied patch:
> {{{
> // get the first (in our case the timstampable) listener for the record
> $timestampable = $record->getListener()->get(0);
>
> // disable setting of created_at at the timestampable listener
> $timestampable->setOption(array('created' => array('disabled' => true)));
> }}}
New description:
As discussed in the mailing-list, I attached a patch which adds a
$_options class var + getter/setter method to the Doctrine_Record_Listener
class, which would give us the opportunity to dis-/enable record listener
at runtime.
This solution is working if the Listener are checking their options array
at the corresponding hooks like the bundled Timstampable listener and many
others does.
Example code to disable the timestampable (in this example the first
attached listener) listener at runtime with the applied patch:
{{{
// get the first (in our case the timstampable) listener for the record
$timestampable = $record->getListener()->get(0);
// disable setting of created_at at the timestampable listener
$timestampable->setOption(array('created' => array('disabled' => true)));
}}}
--
Comment:
In r5236 I commited an implementation to support this. Thanks for the
patch, it inspired me a lot!
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1590#comment:4>