[development] Rename hook_menu ?

Dries Buytaert dries.buytaert at gmail.com
Wed Dec 13 07:43:57 UTC 2006


On 12 Dec 2006, at 22:19, Michael Favia wrote:
> Karoly Negyesi wrote:
>> Today it was raised in #drupal that hook_menu has so little to do  
>> with
>> menus nowadays that
>
> I was initially confused by this and underestimated the hooks  
> importance
> and functionality. At first i thought the name wasn't as important as
> it's proper documentation as a pillar of the drupal system. But  
> after a
> moment of reflection, I remember being confused by this on my first  
> time
> through as well.
>
> I'm not saying the documentation isn't there I'm just relating that i
> didn't find it by default like I found FAPI and the other hooks
> intuitive, etc probably because it was called a Menu system and I
> discounted it as what i was looking for. Anything more descriptive
> sounds good to me. Control, route, path, etc. I hope I would have
> noticed any of those for what they are.

Great feedback, Michael. I know a few people that told me the exact  
same story.  Karoly senses this as well -- otherwise he would not  
have made the suggestion.  It's a real problem and I think we should  
fix it.

Renaming hook_menu() causes some pain, but in the long term, it will  
pay off.  As we are going to completely overhaul the menu system in  
Drupal 6, this is the right time to make semantic improvements.  Like  
it or not, but your menu code is going to break anyway.

Thus, I'm in favor of renaming hook_menu() to hook_router() as that  
is semantically more accurate and matches the terminology used in  
other systems (eg. RoR and PEAR).

I'd be happy to debate and weigh alternative names but let's not  
invent new terminology for an existing pattern.  Let's go with  
hook_router() for now, or come up with a list of names that other  
systems use.

Thanks,

--
Dries Buytaert  ::  http://www.buytaert.net/


More information about the development mailing list