fix: #3641335 The Instances menu swap is decided once for every user

Resolves #3641335 by replacing the menuLinksDiscoveredAlter hook with a dedicated DisplayBuilderMenuLink plugin class extending MenuLinkDefault.

  • Dynamically selects the route (entity.display_builder_instance.collection vs entity.display_builder_profile.collection) based on current user permissions at render time rather than statically baking it during discovery rebuild.
  • Adds user.permissions cache context.
  • Adds Kernel test DisplayBuilderMenuLinkTest validating route resolution across different user roles and verifying menu rebuilds do not corrupt the link for other users.

Closes #3641335


AI Disclosure: Code, tests, and MR description were drafted with the assistance of an AI tool (Antigravity/LLM), and manually verified and tested.

Merge request reports

Loading
Loading