Timeline for How does module_hook() function work?
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 8, 2015 at 9:50 | comment | added | Clive♦ |
Oh it's totally proper to reflect on comment blocks - Drupal 8, and pretty much all modern frameworks, use the technique extensively for annotation-based meta data. It's a lot easier than you might think, too. e.g. $reflection = new ReflectionFunction('block_help'); $comment = $reflection->getDocComment() . $comment will contain "Implements hook_help().", which you could string match against. It should be foolproof for core, where documentation should be perfectly in keeping with standards. It's just contrib you have to worry about
|
|
Apr 8, 2015 at 9:42 | vote | accept | Pravin Ajaaz | ||
Apr 8, 2015 at 9:40 | comment | added | Pravin Ajaaz | I finally gained a valuable information that "Drupal (and also I) doesn't actually know the difference between a function and a hook." ;) Thanks Clive.. ;) It's time for me to find other possible ways of doing it. Maybe I should stick with your earlier suggestion of reading the "Comment Blocks" :) I thought it was not proper but now I am sure that's the only way of doing it. | |
Apr 8, 2015 at 9:32 | comment | added | Clive♦ | @PravinAjaaz I don't disagree with you in principle, but let's face it: PHP is a pretty crappy, loosely typed, language (which used to be even worse than it is now in versions that Drupal 7 needs to support for historical reasons). You can't really blame people for building crappy, loosely typed systems on top of it ;) I should disclaim that I say that in jest, I'm not disparaging those that implemented it! | |
Apr 8, 2015 at 9:29 | comment | added | Pravin Ajaaz | So its time for me to stop the search for such a function. But there are a lot of contrib modules which uses the module name as the beginning of a function name. May be the standard to name so should be strictly stated in the beginning. :( Anyway thanks clive :) | |
Apr 8, 2015 at 9:25 | history | edited | Clive♦ | CC BY-SA 3.0 |
deleted 4 characters in body
|
Apr 8, 2015 at 9:19 | history | edited | Clive♦ | CC BY-SA 3.0 |
added 191 characters in body
|
Apr 8, 2015 at 9:15 | history | answered | Clive♦ | CC BY-SA 3.0 |