You are here

public static function TextHeaderFormatter::isApplicable in Header formatter 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/TextHeaderFormatter.php, line 35

Class

TextHeaderFormatter
Plugin implementation of the 'text_header' formatter.

Namespace

Drupal\header_formatter\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  if (!parent::isApplicable($field_definition)) {
    return FALSE;
  }
  $cardinality = $field_definition
    ->getFieldStorageDefinition()
    ->getCardinality();
  return $cardinality === 1;
}