Problem/Motivation
While using Preview Link 2.2.1 together with Salesforce Mapping 5.1.3, opening the canonical page of a salesforce_mapped_object entity throws the following exception:
`Symfony\Component\Routing\Exception\RouteNotFoundException:
Route "entity.salesforce_mapped_object.preview_link_generate" does not exist.`
The problem is caused by inconsistent checks within the Preview Link module.
PreviewLinkTasks determines whether an entity supports preview links by calling:
PreviewLinkUtility::isEntityTypeSupported()
which currently returns:
return $entityType->isRevisionable()
&& $entityType->hasLinkTemplate('canonical');
Since salesforce_mapped_object is revisionable and has a canonical link template, Preview Link generates a local task for:
entity.salesforce_mapped_object.preview_link_generate
However, the entity does not define a preview-link-generate link template, so the corresponding route is never created, resulting in a RouteNotFoundException when Drupal renders the local tasks.
Steps to reproduce
- Install Preview Link 2.2.1.
- Install Salesforce Mapping 5.1.3.
- Ensure salesforce_mapped_object is revisionable and has a canonical route.
- Open the canonical page for a Salesforce mapped object.
- Observe the exception:
Symfony\Component\Routing\Exception\RouteNotFoundException:
Route "entity.salesforce_mapped_object.preview_link_generate" does not exist.
Proposed resolution
PreviewLinkUtility::isEntityTypeSupported() should also verify that the entity defines the required preview-link-generate link template.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | preview_link-require-preview-link-template.patch | 561 bytes | pranav45 |
| Details _ previewlinkissue.png | 713.28 KB | pranav45 |
Comments
Comment #2
pranav45 commentedI've attached a proposed patch that updates
`PreviewLinkUtility::isEntityTypeSupported()`to require the `preview-link-generate` link template in addition to the existing checks.Summary
Currently,
`isEntityTypeSupported()`returns `TRUE` for any revisionable entity with a canonical link template. As a result, `PreviewLinkTasks` generates a local task for entities such as `salesforce_mapped_object`.However, `salesforce_mapped_object` does not define a `preview-link-generate` link template, so the route `entity.salesforce_mapped_object.preview_link_generate` is never created. When Drupal renders the local tasks on the entity's canonical page, it throws a `RouteNotFoundException`.
This patch aligns the support check with the requirements of `PreviewLinkRouteProvider` by ensuring that only entity types defining the `preview-link-generate` link template are considered Preview Link-supported.
I reproduced this issue with Preview Link 2.2.1 and Salesforce Mapping 5.1.3, but the underlying issue appears to be generic and could affect any revisionable entity type that has a canonical route but does not define the `preview-link-generate` link template.
Feedback is welcome if maintainers would prefer this validation to be implemented elsewhere (for example, within the route provider) to keep the task generation and route generation logic in sync.