3 namespace Drupal\field_test\Plugin\Field\FieldFormatter;
4 use Drupal\Core\Field\FieldDefinitionInterface;
5 use Drupal\Core\Field\FieldItemListInterface;
6 use Drupal\Core\Field\FormatterBase;
10 * Plugin implementation of the 'field_test_applicable' formatter.
12 * It is applicable to test_field fields unless their name is 'deny_applicable'.
15 * id = "field_test_applicable",
16 * label = @Translation("Applicable"),
17 * description = @Translation("Applicable formatter"),
24 class TestFieldApplicableFormatter extends FormatterBase {
29 public static function isApplicable(FieldDefinitionInterface $field_definition) {
30 return $field_definition->getName() != 'deny_applicable';
36 public function viewElements(FieldItemListInterface $items, $langcode) {
37 return ['#markup' => 'Nothing to see here'];