You are here

public static function PictureBackgroundFormatterMedia::isApplicable in Picture Background 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/PictureBackgroundFormatterMedia.php, line 69

Class

PictureBackgroundFormatterMedia
Plugin implementation of the 'picture_background_formatter_media' formatter.

Namespace

Drupal\picture_background_formatter\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {

  // This formatter is only available for entity types that reference
  // media entities.
  $target_type = $field_definition
    ->getFieldStorageDefinition()
    ->getSetting('target_type');
  return $target_type == 'media';
}