Closed (fixed)
Project:
Open Social
Version:
8.x-6.x-dev
Component:
Code (back-end)
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Jun 2019 at 12:39 UTC
Updated:
1 Jul 2019 at 15:59 UTC
Jump to comment: Most recent
Comments
Comment #2
kingdutchHi!
I suspect this is mostly a legacy thing. This code has existed within Open Social for a relatively long time so it's possible that whoever first build it decided that it was the best solution with the tools available in Drupal 8 at that moment.
Another good reason is that the hook implementation route means that each module has a standardised way to implement their possible addition for the menu. This ensures that new items from modules that implement content types or things that can be created are automatically picked up in the menu.
Changing this over to a menu could break existing sites that extend the system through hooks. It could also cause the site manager to inadvertently delete or duplicate navigational items that are crucial for the Open Social experience.
I hope this answers your question, please let me know if anything is unanswered/unclear.
~ Kingdutch
Comment #3
the_glitch commentedThanks for answering that for me. As a site builder that can't program, this is going to make adding menu items difficult for me. It seems that I should probably leave these menus in the hook implementation format.
Could you, or anybody else reading this, please point me to where the code is that's responsible for the [+] menu so I can have a look and maybe work out how to add new content types to that menu?
Any other leads, tips or advice would be greatly appreciated.
Comment #4
kingdutchThe entire menu (including the user profile dropdown and notification center) is build by the
AccountHeaderBlockwhich is found in thesocial_usermenu.The various modules in Open Social implement the
hook_social_user_account_header_create_linkshook. This is documented in thesocial_user.api.phpfile.You can also look at
social_topic_social_user_account_header_create_linksin thesocial_topicmodule for an example implementation. The API file still needs to be updated to use the render array pattern of the Url to automatically handle access checks. This has been done in thesocial_topicimplementation.Ideally modules that want to support Open Social and provide content types would simply implement this hook. It does nothing outside of Open Social so there's no harm in shipping it. Alternatively someone in the community could build a module that would implement this hook and simply translate a menu into additional items to be rendered. That could then be used by site builders.
Comment #5
tepelena commentedIt's funny, I have the same issue.
Don't see why this needs to be implemented through hooks.
The best solution would be to have it a Drupal menu.