TestFieldApplicableFormatter.php in Drupal 9
File
core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php
View source
<?php
namespace Drupal\field_test\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
class TestFieldApplicableFormatter extends FormatterBase {
public static function isApplicable(FieldDefinitionInterface $field_definition) {
return $field_definition
->getName() != 'deny_applicable';
}
public function viewElements(FieldItemListInterface $items, $langcode) {
return [
'#markup' => 'Nothing to see here',
];
}
}