You are here

public static function FileExtensionFormatter::isApplicable in Drupal 10

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

File

core/modules/file/src/Plugin/Field/FieldFormatter/FileExtensionFormatter.php, line 70

Class

FileExtensionFormatter
Formatter to render a filename as file extension.

Namespace

Drupal\file\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {

  // Just show this file extension formatter on the filename field.
  return parent::isApplicable($field_definition) && $field_definition
    ->getName() === 'filename';
}