function OEmbedWidget::isApplicable

Same name in other branches
  1. 8.9.x core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php \Drupal\media\Plugin\Field\FieldWidget\OEmbedWidget::isApplicable()
  2. 10 core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php \Drupal\media\Plugin\Field\FieldWidget\OEmbedWidget::isApplicable()
  3. 11.x core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php \Drupal\media\Plugin\Field\FieldWidget\OEmbedWidget::isApplicable()

Overrides WidgetBase::isApplicable

File

core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php, line 55

Class

OEmbedWidget
Plugin implementation of the 'oembed_textfield' widget.

Namespace

Drupal\media\Plugin\Field\FieldWidget

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.