You are here

function Piwik::validateUrl in Analytics 8

File

analytics_piwik/src/Plugin/AnalyticsService/Piwik.php, line 52

Class

Piwik
Analytics service type.

Namespace

Drupal\analytics_piwik\Plugin\AnalyticsService

Code

function validateUrl($element, &$form_state) {
  $value = $element['#value'];
  if ($value != '') {

    // Make sure the URL is normalized.
    $value = rtrim($value, '/') . '/';
    form_set_value($element, $value, $form_state);
    if (!valid_url($value, TRUE)) {
      form_error($element, t('%name is not a valid URL.', [
        '%name' => $element['#title'],
      ]));
    }
    else {
      $request = drupal_http_request($value . '/piwik.js');
    }
  }
}