- Issue created by @sir_squall
- 🇬🇧United Kingdom dieppon
Hi,
I have added a hook_entity_operation() using the code from the hook_menu_local_tasks_alter() it will be need so love but it works.
- First commit to issue fork.
- Merge request !6Issue #3383353 by dieppon, orakili, sir_squall: Add operation link to clone entity in admin content → (Merged) created by orakili
- Assigned to orakili
- Status changed to Needs review
9 months ago 4:38am 3 April 2024 - 🇯🇵Japan orakili
MR based on patch from @dieppon: https://git.drupalcode.org/project/content_entity_clone/-/merge_requests/6 with some refactoring to reduce duplicate code.
Note: this will be adjusted to handle translation when tackling https://www.drupal.org/project/content_entity_clone/issues/3423495 🐛 Cloning a translation of an entity loads the original entity Needs review .
- First commit to issue fork.
- 🇷🇸Serbia vaish
I was about to create new issue when I noticed that it was already fixed in this MR so I decided to add an additional related fix here instead of creating new issue. These are the issues I'm referring to:
1. Query string is missing when "Clone" local task is displayed in the admin toolbar. This requires that admin_toolbar_tools module is enabled and "Enable/Disable local tasks display" setting is turned on. This has been fixed in this MR by adding the third parameter
$options
to theUrl::fromRoute()
call.$options = [ 'query' => [ 'content_entity_clone' => $entity->id(), ], ]; $url = Url::fromRoute($entity_creation_route_name, $entity_creation_route_parameters, $options);
2. I also run into the issue 🐛 Undefined array key "#active" in Drupal\admin_toolbar_tools\AdminToolbarToolsHelper->buildLocalTasksToolbar() Needs review . As per the docs local task is expected to have "#active" key but in this case key was not defined. Unfortunately, I had trouble reproducing this issue. I'm getting it on a project with many contrib and custom modules but not on the clean Drupal install. I still think it makes sense to define this key. Value will always be FALSE because it's impossible for "Clone" tab to ever be active.
3. I also fixed some minor typos.
Additionally, I noticed that this MR also fixes 🐛 Where is the link to create a clone from node? Closed: duplicate . Marking that other issue as duplicate.
- 🇯🇵Japan orakili
Thank you for fixing the typos.
I couldn't reproduce the issue with the `#active` key but I didn't see any adverse effects of having it defined so that looks good to me. Thanks.
- Status changed to RTBC
8 months ago 10:51am 10 April 2024 - 🇷🇸Serbia vaish
Thanks @orakili. MR looks good to me (both code and functionality) and if you are fine with the changes I made I think this can be moved to RTBC.
- Status changed to Fixed
8 months ago 1:26am 15 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.