Closed (fixed)
Project:
Flag
Version:
6.x-2.x-dev
Component:
User interface
Priority:
Critical
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Apr 2009 at 18:26 UTC
Updated:
28 Sep 2009 at 14:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
quicksketchThis patch doesn't seem correct. If possible, it'd be better to only call drupal_alter() in one place, though I admit it doesn't look like there's a real good place to do this currently, unless we add another loop at the bottom of the flag_get_flags() function to do the drupal_alter(). Either way though, the current location of the drupal_alter() calls is not correct, as the first call doesn't even get a real flag, it just gets a database row.
Comment #2
aaron commentedwell, here it is with a loop then.
Comment #3
mooffie commentedA more powerful approach is to let programmers alter the handlers' definitions. In other words, to put the following in flag_fetch_definition():
(The "$cache" variable, in that funciton, should be renamed to "$definitions", for clarity.)
It's a more powerful approach because it lets you alter the behavior of flags. Not just their data.
For example, in your module you could then do:
It was my plan all along to add this feature, so:
+1
Comment #4
mooffie commentedTomorrow, I hope, I'll write about one problem in this scheme.
Comment #5
mooffie commentedOh, I'll make it short:
With the above scheme, only one module could override the handler class name.
(The real culprit is PHP's lousy object model, which provides us with very little power, if at all. It's beyond my understanding how some programmers believe PHP5 is somehow better than PHP3.)
Comment #6
mooffie commentedI want to retract some of my criticism of PHP. PHP5 provides us with some features that enable us to implement a delegator (sometimes called a "proxy").
So this is not true, because modules could install a delegator on
$definitions['node']['handler']. When several modules do this simultanously, a chain will be formed, and everybody will be happy.Here's the example from comment #3, but now revised to use a delegator:
(The code was not tested, but it's largly correct.)
Comment #7
mitchell commentedMarked #347082: Add hook_flag_alter() as a duplicate of this issue.
Comment #8
quicksketchmooffie: any reason why we shouldn't add that patch as-is? Considering delegators are PHP 5 only, and current knowledge of how to use them is pretty minimal (self included). Contrary to hook_flag_alter(), which is a well-understood convention in Drupal.
I'm personally okay with #2.
Comment #9
quicksketchCommitted #2 to the 2.x version.