public static function OEmbedFormatter::isApplicable in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php \Drupal\media\Plugin\Field\FieldFormatter\OEmbedFormatter::isApplicable()
- 9 core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php \Drupal\media\Plugin\Field\FieldFormatter\OEmbedFormatter::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 FormatterBase::isApplicable
File
- core/
modules/ media/ src/ Plugin/ Field/ FieldFormatter/ OEmbedFormatter.php, line 300
Class
- OEmbedFormatter
- Plugin implementation of the 'oembed' formatter.
Namespace
Drupal\media\Plugin\Field\FieldFormatterCode
public static function isApplicable(FieldDefinitionInterface $field_definition) {
if ($field_definition
->getTargetEntityTypeId() !== 'media') {
return FALSE;
}
if (parent::isApplicable($field_definition)) {
$media_type = $field_definition
->getTargetBundle();
if ($media_type) {
$media_type = MediaType::load($media_type);
return $media_type && $media_type
->getSource() instanceof OEmbedInterface;
}
}
return FALSE;
}