Version 1
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Plugin / Field / FieldFormatter / EntityTestReferenceCustomCacheTagFormatter.php
diff --git a/web/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldFormatter/EntityTestReferenceCustomCacheTagFormatter.php b/web/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldFormatter/EntityTestReferenceCustomCacheTagFormatter.php
new file mode 100644 (file)
index 0000000..76fb12f
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\entity_test\Plugin\Field\FieldFormatter;
+
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
+
+/**
+ * Plugin implementation of the 'entity_reference_custom_cache_tag' formatter.
+ *
+ * @FieldFormatter(
+ *   id = "entity_reference_custom_cache_tag",
+ *   label = @Translation("Custom cache tag"),
+ *   field_types = {
+ *     "entity_reference"
+ *   }
+ * )
+ */
+class EntityTestReferenceCustomCacheTagFormatter extends EntityReferenceFormatterBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function viewElements(FieldItemListInterface $items, $langcode) {
+    return ['#cache' => ['tags' => ['custom_cache_tag']]];
+  }
+
+}