EntityTestReferenceCustomCacheTagFormatter.php

Same filename and directory in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldFormatter/EntityTestReferenceCustomCacheTagFormatter.php
  2. 8.9.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldFormatter/EntityTestReferenceCustomCacheTagFormatter.php
  3. 10 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldFormatter/EntityTestReferenceCustomCacheTagFormatter.php

Namespace

Drupal\entity_test\Plugin\Field\FieldFormatter

File

core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldFormatter/EntityTestReferenceCustomCacheTagFormatter.php

View source
<?php

namespace Drupal\entity_test\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\Attribute\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Plugin implementation of the 'entity_reference_custom_cache_tag' formatter.
 */
class EntityTestReferenceCustomCacheTagFormatter extends EntityReferenceFormatterBase {
    
    /**
     * {@inheritdoc}
     */
    public function viewElements(FieldItemListInterface $items, $langcode) {
        return [
            '#cache' => [
                'tags' => [
                    'custom_cache_tag',
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
EntityTestReferenceCustomCacheTagFormatter Plugin implementation of the 'entity_reference_custom_cache_tag' formatter.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.