You are here

public static function EntityReferenceEntityFormatter::isApplicable in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter::isApplicable()
  2. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter::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

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php, line 213

Class

EntityReferenceEntityFormatter
Plugin implementation of the 'entity reference rendered entity' formatter.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {

  // This formatter is only available for entity types that have a view
  // builder.
  $target_type = $field_definition
    ->getFieldStorageDefinition()
    ->getSetting('target_type');
  return \Drupal::entityTypeManager()
    ->getDefinition($target_type)
    ->hasViewBuilderClass();
}