#1590: [PATCH] Doctrine_Record_Listener options getter/setter to  dis-/enable
listener at runtime
--------------------------+-------------------------------------------------
  Reporter:  su           |       Owner:  romanb                   
      Type:  enhancement  |      Status:  closed                   
  Priority:  minor        |   Milestone:  1.2.0                    
 Component:  Record       |     Version:  1.0.3                    
Resolution:  fixed        |    Keywords:  record, listener, runtime
  Has_test:  0            |    Mystatus:  Pending Core Response    
 Has_patch:  1            |  
--------------------------+-------------------------------------------------
Changes (by guilhermeblanco):

  * 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>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to