Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / field / tests / modules / field_test / src / Plugin / Field / FieldFormatter / TestFieldApplicableFormatter.php
1 <?php
2
3 namespace Drupal\field_test\Plugin\Field\FieldFormatter;
4
5 use Drupal\Core\Field\FieldDefinitionInterface;
6 use Drupal\Core\Field\FieldItemListInterface;
7 use Drupal\Core\Field\FormatterBase;
8
9 /**
10  * Plugin implementation of the 'field_test_applicable' formatter.
11  *
12  * It is applicable to test_field fields unless their name is 'deny_applicable'.
13  *
14  * @FieldFormatter(
15  *   id = "field_test_applicable",
16  *   label = @Translation("Applicable"),
17  *   description = @Translation("Applicable formatter"),
18  *   field_types = {
19  *     "test_field"
20  *   },
21  *   weight = 15,
22  * )
23  */
24 class TestFieldApplicableFormatter extends FormatterBase {
25
26   /**
27    * {@inheritdoc}
28    */
29   public static function isApplicable(FieldDefinitionInterface $field_definition) {
30     return $field_definition->getName() != 'deny_applicable';
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function viewElements(FieldItemListInterface $items, $langcode) {
37     return ['#markup' => 'Nothing to see here'];
38   }
39
40 }