You are here

public static function BlazyOEmbedFormatter::isApplicable in Blazy 8.2

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/BlazyOEmbedFormatter.php, line 132

Class

BlazyOEmbedFormatter
Plugin for blazy oembed formatter.

Namespace

Drupal\blazy\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  if ($field_definition
    ->getTargetEntityTypeId() !== 'media') {
    return FALSE;
  }
  if ($media_type = $field_definition
    ->getTargetBundle()) {
    $media_type = MediaType::load($media_type);
    return $media_type && $media_type
      ->getSource() instanceof OEmbedInterface;
  }
  return FALSE;
}