You are here

protected function AmpAnalytics::elementValidateConfigUrl in Analytics 8

File

analytics_amp/src/Plugin/AnalyticsService/AmpAnalytics.php, line 76

Class

AmpAnalytics
Provides AMP analytics.

Namespace

Drupal\analytics_amp\Plugin\AnalyticsService

Code

protected function elementValidateConfigUrl(array &$element, FormStateInterface $form_state) {
  $value = $element['#value'];
  if ($value == '') {
    return;
  }
  elseif (\Drupal::service('stream_wrapper_manager')
    ->isValidUri($value)) {

    // Allow file URIs like public:://config.json.
    return;
  }
  elseif (!UrlHelper::isExternal($value)) {
    $form_state
      ->setError($element, $this
      ->t('Not a valid URL.'));
  }
}