public function OEmbedForm::validateUrl in Drupal 9
Same name and namespace in other branches
- 8 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());
}
}
}