Closed (fixed)
Project:
Menu migration
Version:
4.1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
20 Nov 2025 at 12:13 UTC
Updated:
5 Dec 2025 at 16:29 UTC
Jump to comment: Most recent
There is no way to to alter the menu items, based on the import/target menu ... as it's not available.
Try to change the language of the menu items, based on the import/target menu.
Make the Import/target menu available on MenuImportEvent.
There are several ways to do it ...
Maybe the easiest way it's to set before the event dispatch, and maybe also added the export/source as extra value (source_menu, origin_menu ...) for the item so maybe also the source menu could be used ... if needed.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bbu23Hi @vasike,
Thanks for reporting this task.
Since we already have the target menu name available in the function where the MenuImportEvent is available, we can simply add it there to the event, and update the event class to expect this new argument.
While indeed the option to add it the item is also a possibility, I might prefer the object approach. As for the "source menu" we'll have to evaluate the options that we have or just rely on the exported information in the item. The
menu_namevalue is supposed to be the exported menu (which is considered the source menu when imported) at that time. It's overridden a few lines later.Though we should keep in mind that "source menu" is not a type of information that is mandatory and it's not something that applies globally to all plugins.
Comment #3
vasike@bbu23 thank you for feedback
I suggested this "quick" solution ... as it's a kind of "hardcoded" in the service provided by the plugin as far I read from the module code.
For me it's ok to pass to Event ... but
What if for some conditions and in some cases, maybe, I want to change the "destination menu" or not import at all ...
But also this "flexibility" could affect maybe some already customisations of this module.
please let me know, which way would you choose for this, so I could create a MR ...
Comment #4
bbu23Sure, I understand that.
Yes, let's go for the Event, you can also add the source menu nullable if needed. And I think this should do it for this ticket*.
As for the rest of the discussion, I see the following:
At the moment, I don't see an immediate need for overriding the target menu. But I remain open to hear specific use cases that people might have in a dedicated ticket. Personally, I'd want to avoid it as much as possible, but who knows? As you said, some cases might arise.
I do see scenarios where we'd want to skip some menu items, so I find this interesting. In fact, there were situations in the past where I would've liked to skip the deletion of specific items prior to import, but that would be a bit complicated to tackle in this ticket.
*The way I see it is: either we include this in the current ticket, and create a flag (using a method) in the Event to specify if the item should be skipped/process, and this would solve it for the import. Or if we want to develop something "bigger" then it could be done in a separate task.
Comment #6
vasikeCreated a MR .. I hope I got it right.
However it seems there are some failures ... but not related with those updates.
Comment #7
bbu23Thanks @vasike, that looks correct though I don't know if you wanted to have also the source_menu or not. If you think the target menu is enough for now, that's good enough for me. But I do wonder if we should rename the property to targetMenu or something similar... 🤔
Regarding the pipeline extra failures, don't worry I'll take care of them.
Comment #8
vasike@bbu23 I mentioned source_menu for the quick solution ... when actually the "final" menu is set before dispatch ...
For me it's ok .. as both values are available in the Subscribers ...
thanks
Comment #9
bbu23Cool, sounds good.
I'll take it from here to solve the pipeline. Thank you!
Comment #11
bbu23Thank you for your contribution.
This will be included in version 4.1.0.
Pending change record & documentation updates.