protected function SoundcloudForm::getMediaType in Media entity Soundcloud 8.2
Same name and namespace in other branches
- 3.x src/Form/SoundcloudForm.php \Drupal\media_entity_soundcloud\Form\SoundcloudForm::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 AddFormBase::getMediaType
File
- src/
Form/ SoundcloudForm.php, line 55
Class
Namespace
Drupal\media_entity_soundcloud\FormCode
protected function getMediaType(FormStateInterface $form_state) {
if ($this->mediaType) {
return $this->mediaType;
}
$media_type = parent::getMediaType($form_state);
if (!$media_type
->getSource() instanceof Soundcloud) {
throw new \InvalidArgumentException('Can only add media types which use an Soundcloud source plugin.');
}
return $media_type;
}