function OEmbedForm::validateUrl
Same name in other branches
- 8.9.x core/modules/media_library/src/Form/OEmbedForm.php \Drupal\media_library\Form\OEmbedForm::validateUrl()
- 10 core/modules/media_library/src/Form/OEmbedForm.php \Drupal\media_library\Form\OEmbedForm::validateUrl()
- 11.x core/modules/media_library/src/Form/OEmbedForm.php \Drupal\media_library\Form\OEmbedForm::validateUrl()
Validates the oEmbed URL.
Parameters
array $form: The complete form.
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
File
-
core/
modules/ media_library/ src/ Form/ OEmbedForm.php, line 153
Class
- OEmbedForm
- Creates a form to create media entities from oEmbed URLs.
Namespace
Drupal\media_library\FormCode
public function validateUrl(array &$form, FormStateInterface $form_state) {
$url = $form_state->getValue('url');
if ($url) {
try {
$resource_url = $this->urlResolver
->getResourceUrl($url);
$this->resourceFetcher
->fetchResource($resource_url);
} catch (ResourceException $e) {
$form_state->setErrorByName('url', $e->getMessage());
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.