Problem/Motivation
In #3547945: Call to a member function getPath() on null, we moved an entity link:
I have tried to move
#[ConfigEntityType(
id: 'pattern_preset',
...
links: [
'edit-form' => '/admin/structure/display-builder/preset/{pattern_preset}',
],
)]
To display_builder_ui module, where the route belongs:
#[Hook('entity_type_alter')]
public function entityTypeAlter(array &$entity_types): void {
$entity_types['pattern_preset']->setLinkTemplate('edit-form', '/admin/structure/display-builder/preset/{pattern_preset}');
}
In order to avoid a fatal error.
Steps to reproduce
Do we need to do the same for other links and handlers with routes managed by display_builder_ui?
Comments
Comment #2
pdureau commentedComment #3
pdureau commentedThe bigger question here is: what happens if I disable
display_builder_ui? Does it breaks?There are currently 3 hard dependencies to
display_builder_uifrom the main module:So, with
display_builder_uidisabled:Profiles
entity.display_builder_profile.collection: ❌ /admin/structure/display-builder :InvalidPluginDefinitionException: The list_builder handler of the "display_builder_profile" entity type specifies a non-existent class "Drupal\display_builder_ui\ProfileListBuilder"entity.display_builder_profile.add-form: /admin/structure/display-builder/add >> ⚠️ Is loading. Is it really what we want?Instances
entity.display_builder_profile.collection: /admin/structure/display-builder/instances >> ✅ 404 NOT FOUNDPresets
entity.pattern_preset.collection: /admin/structure/display-builder/preset >> ✅ 404 NOT FOUNDentity.pattern_preset.add-form: /admin/structure/display-builder/preset/add >> ✅ 404 NOT FOUNDComment #6
andres alvarez commentedConsolidated all UI route links into
DisplayBuilderUiHooks::entityTypeAlter().All nine link templates for
pattern_preset,display_builder_profile, anddisplay_builder_instanceare for routes owned and defined bydisplay_builder_ui.routing.yml. Removed link declarations from entity type annotations (the three entity classes) and moved them to a single place:entityTypeAlter()in the UI module. This makes responsibility clear:display_builder_uimanages routes and their link templates; the main modules no longer need to know about routing.Added
EntityLinkTemplatesTest(Kernel test) that verifies: (1) the links come from the hook, not the annotations, and (2) the link templates resolve to the correct routed paths for both collection and per-entity forms.Kept
edit-plugin-formon the Profile entity, since that route is not managed bydisplay_builder_ui.MR to follow.
Comment #7
andres alvarez commentedComment #8
pdureau commentedThanks a lot Andres.
Before sending to review, can you:
Comment #9
pdureau commentedComment #10
mogtofu33 commented