You are here

public static function FieldFormatterBase::isApplicable in (Entity Reference) Field Formatters 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/FieldFormatterBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterBase::isApplicable()
  2. 8 src/Plugin/Field/FieldFormatter/FieldFormatterBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterBase::isApplicable()

Returns if the formatter can be used for the provided field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition that should be checked.

Return value

bool TRUE if the formatter can be used, FALSE otherwise.

Overrides FormatterBase::isApplicable

File

src/Plugin/Field/FieldFormatter/FieldFormatterBase.php, line 240

Class

FieldFormatterBase
Base class for field formatters.

Namespace

Drupal\field_formatter\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($field_definition
    ->getTargetEntityTypeId());
  return $entity_type
    ->entityClassImplements(FieldableEntityInterface::class);
}