public function OEmbedForm::validateUrl in Media Directories 3.x
Same name and namespace in other branches
- 8 modules/media_directories_ui/src/Form/OEmbedForm.php \Drupal\media_directories_ui\Form\OEmbedForm::validateUrl()
- 2.x modules/media_directories_ui/src/Form/OEmbedForm.php \Drupal\media_directories_ui\Form\OEmbedForm::validateUrl()
Validates the oEmbed URL.
Parameters
array $form: The complete form.
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
File
- modules/
media_directories_ui/ src/ Form/ OEmbedForm.php, line 142
Class
Namespace
Drupal\media_directories_ui\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());
}
}
}