You are here

protected function OEmbedForm::getMediaType in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media_library/src/Form/OEmbedForm.php \Drupal\media_library\Form\OEmbedForm::getMediaType()
  2. 9 core/modules/media_library/src/Form/OEmbedForm.php \Drupal\media_library\Form\OEmbedForm::getMediaType()

File

core/modules/media_library/src/Form/OEmbedForm.php, line 82

Class

OEmbedForm
Creates a form to create media entities from oEmbed URLs.

Namespace

Drupal\media_library\Form

Code

protected function getMediaType(FormStateInterface $form_state) {
  if ($this->mediaType) {
    return $this->mediaType;
  }
  $media_type = parent::getMediaType($form_state);
  if (!$media_type
    ->getSource() instanceof OEmbedInterface) {
    throw new \InvalidArgumentException('Can only add media types which use an oEmbed source plugin.');
  }
  return $media_type;
}