Follow up for #1871772-108: Convert custom blocks to content entities
Problem/Motivation
+++ b/core/modules/block/custom_block/custom_block.module
@@ -5,29 +5,129 @@
+function custom_block_menu_local_tasks_alter(&$data, $router_item, $root_path) {
...
+ if (substr($root_path, 0, 26) == 'admin/structure/block/list') {
...
+ $path_map = explode('/', $root_path);
I just left some remarks in IRC that this implementation of hook_menu_local_tasks_alter() is one of the most complex I've ever seen and that I'm absolutely confident that it can be vastly simplified.
But that's straight refactoring/simplification, so can happen later. :)
That said, in case #1864066: Simplify hook_menu_local_tasks() and MENU_DEFAULT_LOCAL_TASK usage will land first, this hook needs to be adjusted to be not an alter hook, since it adds a local task (instead of altering an existing).
Proposed resolution
Refactor custom_block_menu_local_tasks_alter() once #1864066: Simplify hook_menu_local_tasks() and MENU_DEFAULT_LOCAL_TASK usage lands
Remaining tasks
Write patch
Comment | File | Size | Author |
---|---|---|---|
#7 | drupal8.custom-block-local-action.7.patch | 4.34 KB | sun |
#3 | Screen Shot 2013-02-19 at 4.15.01 PM.png | 18.84 KB | larowlan |
#3 | Screen Shot 2013-02-19 at 4.15.17 PM.png | 17.32 KB | larowlan |
#3 | Screen Shot 2013-02-19 at 4.15.24 PM.png | 23.63 KB | larowlan |
#3 | custom-block-local-tasks-1919926.3.patch | 2.43 KB | larowlan |
Comments
Comment #1
sunSince #1864066: Simplify hook_menu_local_tasks() and MENU_DEFAULT_LOCAL_TASK usage landed in parallel, the current code is definitely broken, as the structure of $data was changed, too.
Comment #2
larowlanworking on it now
Comment #3
larowlanRefactors to use hook_menu_local_tasks() and removes a lot of the logic in favour of preg_match().
Shot from seven (shown as expected)
Shot from bartik (Default theme) (shown as expected)
Shot from other items with same tab root (not shown as expected)
We already had tests for the presence of the link.
Added another to make sure it doesn't show up on other items under tab root.
Comment #4
larowlanComment #5
sunThis still looks a bit too complex to me.
Can you clarify which exact paths we're trying to match? And which ones we don't want to match?
Comment #6
larowlanHey @sun
Basically
admin/structure/block/list/block_plugin_ui:$theme_name/add
for any theme nameComment #7
sunOK, now I understand what's going on. I've added @todos to clarify why this is unnecessarily complex.
For now I referenced #1067408: Themes do not have an installation status since one of its changes is to resolve exactly this. However, we might want to create a separate, dedicated issue for this.
I also removed the 'output' subkey in the returned action array, since that is no longer needed due to #1864066: Simplify hook_menu_local_tasks() and MENU_DEFAULT_LOCAL_TASK usage
Comment #8
larowlanThis is RTBC if bot comes back green.
Comment #9
catchLooks fine. Committed/pushed to 8.x.