You are here

function _ip_ban_validate_paths in IP Ban 8

Same name and namespace in other branches
  1. 7 ip_ban.admin.inc \_ip_ban_validate_paths()

Custom validation function for path redirects.

Custom validation function for the path to redirect to for banned or read-only users. Here we simply ensure the path specified exists, and if not, display a form error.

1 call to _ip_ban_validate_paths()
ip_ban_validate in ./ip_ban.admin.inc
Custom form validation function.

File

./ip_ban.admin.inc, line 154
Administration functions for the IP Ban module.

Code

function _ip_ban_validate_paths($form_element, $form_value) {

  // An empty path is valid here because the path is not a required field.
  if (!empty($form_value) && htmlspecialchars_decode($form_value) != '<front>') {
    $normal_path = drupal_get_normal_path($form_value);
    if (!\Drupal::service("path.validator")
      ->isValid($normal_path)) {
      form_set_error($form_element, t('The path entered does not exist or you do not have permission to access it.'));
    }
  }
}