You are here

public static function StatusPropertyFormatter::isApplicable in Apigee Edge 8

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/StatusPropertyFormatter.php, line 102

Class

StatusPropertyFormatter
Plugin implementation of the 'status_property' formatter.

Namespace

Drupal\apigee_edge\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $entity_type = $field_definition
    ->getTargetEntityTypeId();
  $entity_type_def = \Drupal::entityTypeManager()
    ->getDefinition($entity_type);

  // This field formatter is only applicable on Apigee Edge module's entities
  // and only on their status properties.
  return $field_definition
    ->getName() === 'status' && in_array(EdgeEntityInterface::class, class_implements($entity_type_def
    ->getOriginalClass()));
}