Closed (fixed)
Project:
Flag
Version:
8.x-4.x-dev
Component:
Documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Mar 2015 at 08:25 UTC
Updated:
23 Apr 2015 at 19:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Palashvijay4O commentedUploading a patch.
Comment #3
Palashvijay4O commentedSorry created a patch against wrong branch. Here's the right one. Please review. Thanks !
Comment #4
joachim commentedThanks for working on this. Patch looks perfect.
Do you also want to have a go at creating a draft change record?
Comment #5
Palashvijay4O commentedYeah sure I can give a try!!
Comment #6
joachim commentedGreat! Paste the link here when you want me to take a look at it.
Comment #7
Palashvijay4O commentedhttps://www.drupal.org/node/2462383
This is a draft .. Please let me know is that enough or need to add more things.
Comment #8
joachim commentedIt looks like you've copied the table row from the issue about all the hooks. That's not quite the right approach here. We need something that explains what the hook was used for, and what you're meant to do now. Both should give code examples.
I've had a quick search of core CRs, looking for the word 'removed'. Here's one that's the same sort of thing, though it covers 2 hooks: https://www.drupal.org/node/2420295
Comment #9
Palashvijay4O commentedI am kind of stuck on this.. Can you tell me something more.. not able to find how this was implemented in D7
Comment #10
joachim commentedSure :)
We need to give an example of using this hook. Ideally, we want something realistic. We could make something up -- eg, change the text of one of the flag's labels.
Or perhaps we can find a real implementation. Flag doesn't implement its own hook (sometimes modules do, but generally not). If I google for 'implements hook_flag_alter', I get two results that are implementations:
- http://cgit.drupalcode.org/commons_follow/tree/commons_follow.module?id=...
- http://totemdrupal.com/docs/html/a00014.html
...and they both look like crack to me. Altering the subtypes the flag applies to seems crazy to me. But heyho. It's a use case, apparently.
Let's forget about all the logic these implementations do though. That's overkill. So all we really want is something like:
Of course I don't recall offhand the structure of $flag->types, so that bit could be nonsense... :)
Comment #11
Palashvijay4O commentedThanks! After doing little research I am able to get what's going on here. Let me summarize to you once if I am thinking right. Since drupal_alter is moved to bootstrap.inc so this will be loaded on every Drupal request therefore so request to every module extending hook_flag_alter will be made. So there is now need to hook_flag_alter explicitly...
Please let me know if what I get is right?
Comment #12
joachim commentedI think you're on the wrong track with chasing drupal_alter()...
Here's a rough overview:
On D7, hook_flag_alter() was invoked whenever a flag configuration object was loaded. This allowed other modules to change properties of flags from their stored settings. For example, a module could dynamically change the entity bundles a flag applied to, or the flag's UI labels.
On D8, a flag is a configuration entity. Drupal core invokes hook_entity_load() and hook_ENTITY_TYPE_load() on all entities of all types when they are loaded. Either of these hooks can be used to accomplish the same things as hook_flag_alter() on D7. (Though obviously we recommend using hook_ENTITY_TYPE_load() in our example.)
Is that clearer?
Comment #13
Palashvijay4O commented@joachim its clearer but I am not so good at documenting. I would like you or someone else to publish the change record so that I can learn some more things.
Thank you for the support!!
Comment #14
joachim commentedNo problem.
Looks like you actually made 2 CRs. I've marked one as a duplicate, and written up the other one: https://www.drupal.org/node/2462383.
Comment #15
joachim commentedPatch was good, so committed it.
Thanks for working on this!