- Issue created by @mrddthi
- Merge request !5Issue #3540132 by thidd: Canonical and shortlink of snippet pages are under admin path/route → (Open) created by Unnamed author
Snippet page has unvaluable html_head_link, which are: canonical and shortlink of "/admin/structure/snippet/{snippet}"
The issue cause because of the Drupal\snippet_manager\EventSubscriber\RouteSubscriber::buildRoute
given the _entity_view: 'snippet.full'
. Therefore, EntityRouteEnhancer::enhanceEntityView()
automatically add $defaults['_controller'] = '\Drupal\Core\Entity\Controller\EntityViewController::view';
And result are:
1. The controller found the snippet hasLinkTemplate
of canonical
2. the EntityViewController
add the html_head_link
within the canonical link.
3. The shared Snippet page on other social network can not get the preview (got access denied)
1. Create new SnippetViewController extend EntityViewController
.
2. Update the RouteSubscriber::builtRoute()` to add `$defaults['_controller'] = SnippetViewController;
3. in SnippetViewController::view()
, update the canonical, shortlink href by getting snippet page path.
4. Dispatch hook_snippet_view_controller_alter
for alter the $page result in SnippetViewController::view()
.
Needs review
2.0
Code