You are here

protected function OEmbedForm::getMediaType in Media Directories 8

Same name and namespace in other branches
  1. 3.x modules/media_directories_ui/src/Form/OEmbedForm.php \Drupal\media_directories_ui\Form\OEmbedForm::getMediaType()
  2. 2.x modules/media_directories_ui/src/Form/OEmbedForm.php \Drupal\media_directories_ui\Form\OEmbedForm::getMediaType()

Get the media type from the form state.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

Return value

\Drupal\media\MediaTypeInterface The media type.

Throws

\InvalidArgumentException If the selected media type does not exist.

Overrides AddMediaFormBase::getMediaType

1 call to OEmbedForm::getMediaType()
OEmbedForm::buildInputElement in modules/media_directories_ui/src/Form/OEmbedForm.php
Inheriting classes need to build the desired input element.

File

modules/media_directories_ui/src/Form/OEmbedForm.php, line 76

Class

OEmbedForm
A form to add remote content using OEmbed resources.

Namespace

Drupal\media_directories_ui\Form

Code

protected function getMediaType(FormStateInterface $form_state) {
  $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;
}