- Issue created by @rupertj
- 🇬🇧United Kingdom joachim
The canonical link template is there because Drupal Code Builder generates it for config entities. I'll fix that too.
- 🇬🇧United Kingdom joachim
I've got a feeling I added this in DCB so that Devel module gives us a devel tab on Finder entities.
Core doesn't expect that a canonical route necessarily means there's a view builder -- in DefaultHtmlRouteProvider:
if ($entity_type->hasLinkTemplate('canonical') && $entity_type->hasViewBuilderClass()) {
- 🇬🇧United Kingdom rupertj Bristol, UK
Yup, and that's the code that causes the problem by going on to not create the routing for the canonical link.
If you look through EntityBase::toUrl(), that checks to see if there's a canonical link template. If there is, it uses the (missing) route. If there isn't a canonical link template, it falls back to the edit-form link template. I think this behaviour is what we want to happen.
I feel like the pragmatic fix here is to take out canonical from the Finder entity, but there's arguably something that should be done better in core. (Maybe adding Drupal\Core\Entity\EntityViewBuilder as the view_builder for entities that declare a canonical route template and no view_builder?)
- 🇬🇧United Kingdom rupertj Bristol, UK
Ignore that linked MR - I pushed to the wrong fork somehow.
- 🇬🇧United Kingdom rupertj Bristol, UK
And I've fixed up the original PR which somehow ended up with the other commit in it. (It's still listed on the activity page, but it's not in the changes): https://git.drupalcode.org/project/finders/-/merge_requests/1
- 🇬🇧United Kingdom joachim
Devel still shows the tab without the link template, so all good.
Merged.
Automatically closed - issue fixed for 2 weeks with no activity.