[Doctrine] #1590: [PATCH] Doctrine_Record_Listener options getter/setter to dis-/enable listener at runtime

10 views
Skip to first unread message

Doctrine

unread,
Oct 21, 2008, 5:42:30 AM10/21/08
to doctri...@googlegroups.com
#1590: [PATCH] Doctrine_Record_Listener options getter/setter to dis-/enable
listener at runtime
---------------------------------------+------------------------------------
Reporter: su | Owner: romanb
Type: enhancement | Status: new
Priority: minor | Milestone: Unknown
Component: Record | Version: 1.0.3
Keywords: record, listener, runtime | Has_test: 0
Mystatus: Pending Core Response | Has_patch: 1
---------------------------------------+------------------------------------
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)));
}}}

--
Ticket URL: <http://trac.doctrine-project.org/ticket/1590>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper

Doctrine

unread,
Oct 21, 2008, 1:36:49 PM10/21/08
to doctri...@googlegroups.com
#1590: [PATCH] Doctrine_Record_Listener options getter/setter to dis-/enable
listener at runtime
--------------------------+-------------------------------------------------
Reporter: su | Owner: romanb
Type: enhancement | Status: new
Priority: minor | Milestone: Unknown
Component: Record | Version: 1.0.3
Resolution: | Keywords: record, listener, runtime
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 1 |
--------------------------+-------------------------------------------------
Comment (by jwage):

Have you applied the patch and ran the test suite to see if it affects
any?

You can run them by doing the following:

{{{
svn co http://svn.doctrine-project.org/branches/1.0 doctrine
cd doctrine/tests
php run.php
}}}

Apply the patch and run the tests again to see if you have any new fails.

--
Ticket URL: <http://trac.doctrine-project.org/ticket/1590#comment:1>

Doctrine

unread,
Oct 21, 2008, 2:48:53 PM10/21/08
to doctri...@googlegroups.com
#1590: [PATCH] Doctrine_Record_Listener options getter/setter to dis-/enable
listener at runtime
--------------------------+-------------------------------------------------
Reporter: su | Owner: romanb
Type: enhancement | Status: new
Priority: minor | Milestone: 1.2.0
Component: Record | Version: 1.0.3
Resolution: | Keywords: record, listener, runtime
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 1 |
--------------------------+-------------------------------------------------
Changes (by jwage):

* milestone: Unknown => 1.2.0

--
Ticket URL: <http://trac.doctrine-project.org/ticket/1590#comment:2>

Doctrine

unread,
Oct 21, 2008, 3:30:35 PM10/21/08
to doctri...@googlegroups.com
#1590: [PATCH] Doctrine_Record_Listener options getter/setter to dis-/enable
listener at runtime
--------------------------+-------------------------------------------------
Reporter: su | Owner: romanb
Type: enhancement | Status: new
Priority: minor | Milestone: 1.2.0
Component: Record | Version: 1.0.3
Resolution: | Keywords: record, listener, runtime
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 1 |
--------------------------+-------------------------------------------------
Comment (by su):

ok test results without my patch:
{{{
Tested: 305 test cases.
Successes: 3575 passes.
Failures: 14 fails.
Number of new Failures: 0
Number of fixed Failures: 0
}}}

test results with my patch applied:
{{{
Tested: 305 test cases.
Successes: 3575 passes.
Failures: 14 fails.
Number of new Failures: 0
Number of fixed Failures: 0
}}}

so it looks like nothing is affected..

--
Ticket URL: <http://trac.doctrine-project.org/ticket/1590#comment:3>

Doctrine

unread,
Dec 2, 2008, 9:30:09 AM12/2/08
to doctri...@googlegroups.com
#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>

Reply all
Reply to author
Forward
0 new messages