System information

  • Drupal Core Version: 11.x
  • Menu Migration Version: 4.x
  • PHP Version: 8.3

Problem/Motivation

There is no way to to alter the menu items, based on the import/target menu ... as it's not available.

Steps to reproduce

Try to change the language of the menu items, based on the import/target menu.

Proposed resolution

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.

Command icon Show commands

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

vasike created an issue. See original summary.

bbu23’s picture

Hi @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_name value 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.

vasike’s picture

Status: Active » Needs work

@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 ...

bbu23’s picture

Sure, 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:

Option to override the destination menu

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.

Option to skip importing specific menu items

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.

vasike’s picture

Status: Needs work » Needs review

Created a MR .. I hope I got it right.

However it seems there are some failures ... but not related with those updates.

bbu23’s picture

Thanks @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.

vasike’s picture

@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

bbu23’s picture

Assigned: Unassigned » bbu23

Cool, sounds good.
I'll take it from here to solve the pipeline. Thank you!

  • bbu23 committed e2e9102d on 4.1.x authored by vasike
    feat: #3559017 Add Import menu name on MenuImportEvent - available for...
bbu23’s picture

Assigned: bbu23 » Unassigned
Status: Needs review » Fixed
Issue tags: +Needs change record, +Needs documentation updates

Thank you for your contribution.

This will be included in version 4.1.0.

Pending change record & documentation updates.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.