.../Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php | 5 +---- .../Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php | 5 +---- .../Drupal/entity_reference/Tests/EntityReferenceFormatterTest.php | 1 - .../Drupal/taxonomy/Plugin/Field/FieldFormatter/LinkFormatter.php | 6 +----- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php index c20038f..6d4c28d 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php @@ -44,10 +44,7 @@ public function viewElements(FieldItemListInterface $items) { // that the referenced entity is deleted, the cache for referring // entities must be cleared. '#cache' => array( - 'tags' => array( - $referenced_entity->getEntityTypeID() => $referenced_entity->id(), - $referenced_entity->getEntityTypeID() . '_view' => TRUE, - ), + 'tags' => $referenced_entity->getCacheTag(), ), ); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index b7157c9..bc305cd 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -79,10 +79,7 @@ public function viewElements(FieldItemListInterface $items) { else { $elements[$delta] = array('#markup' => check_plain($label)); } - $elements[$delta]['#cache']['tags'] = array( - $referenced_entity->getEntityTypeID() => $referenced_entity->id(), - $referenced_entity->getEntityTypeID() . '_view' => TRUE, - ); + $elements[$delta]['#cache']['tags'] = $referenced_entity->getCacheTag(); } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFormatterTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFormatterTest.php index 00140cc..5bbf52c 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFormatterTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFormatterTest.php @@ -117,6 +117,5 @@ public function testIdFormatter() { $this->assertEqual($build[0]['#markup'], $entity_1->id(), format_string('The markup returned by the @formatter formatter is correct.', array('@formatter' => $formatter))); $this->assertEqual($build[0]['#cache']['tags'][$this->entityType], $entity_1->id(), format_string('The @formatter formatter assigned the correct cache tag entity ID.', array('@formatter' => $formatter))); - $this->assertTrue($build[0]['#cache']['tags'][$this->entityType . '_view'], format_string('The @formatter formatter assigned the correct value for the entity type view cache tag.', array('@formatter' => $formatter))); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/LinkFormatter.php index fd2c277..856b73e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -52,11 +52,7 @@ public function viewElements(FieldItemListInterface $items) { unset($item->_attributes); } - $elements[$delta]['#cache']['tags'] = array( - 'taxonomy_term' => $item->entity->id(), - 'taxonomy_term_view' => TRUE, - ); - + $elements[$delta]['#cache']['tags'] = $item->entity->getCacheTag(); } }