You are here

public function ShareEverywhereConfigForm::validateForm in Share Everywhere 8

Same name and namespace in other branches
  1. 2.x src/Form/ShareEverywhereConfigForm.php \Drupal\share_everywhere\Form\ShareEverywhereConfigForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/ShareEverywhereConfigForm.php, line 395

Class

ShareEverywhereConfigForm
Provides a settings form for Share Everywhere module.

Namespace

Drupal\share_everywhere\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $pages = $form_state
    ->getValue('pages');
  if (!empty($pages)) {
    $pages = explode("\r\n", $pages);
    foreach ($pages as $page) {
      if (empty(trim($page))) {
        continue;
      }
      if (array_search('*', preg_split('/\\//', $page, NULL, PREG_SPLIT_NO_EMPTY)) === FALSE) {
        if (!$this->pathValidator
          ->isValid($page)) {
          $form_state
            ->setErrorByName('pages', $this
            ->t('One or more of the restricted pages does not exist. Please specify existing paths in the correct form.'));
        }
      }
    }
  }
}