Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291859

StringFormatter shows link for entities that might not have a canonical URL

$
0
0

Problem/Motivation

The Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter checks in its ::settingsForm method on the entity type, whether it has a canonical link template. That is correct.

However, it also checks for canonical link template existence within ::viewElements on the entity type. Since single entity instance are allowed to define whether they have a canonical link template on their own via EntityInterface::hasLinkTemplate, the StringFormatter should respect that accordingly.

Steps to reproduce

Proposed resolution

Replace the check on entity type level within StringFormatter::viewElements by a check on the entity itself.
Meaning changing this line

if ($this->getSetting('link_to_entity') && !$entity->isNew() && $entity_type->hasLinkTemplate('canonical')) {
to
if ($this->getSetting('link_to_entity') && !$entity->isNew() && $entity->hasLinkTemplate('canonical')) {

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 291859

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>