You are here

public function DisableLanguageSettings::validateForm in Disable language 8

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/DisableLanguageSettings.php, line 109

Class

DisableLanguageSettings
Class DisableLanguageSettings.

Namespace

Drupal\disable_language\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $values = $form_state
    ->getValue('redirect_override_routes');
  $values = $this
    ->explodeToArray($values);
  foreach ($values as $value) {
    try {
      $this->routeProvider
        ->getRouteByName($value);
    } catch (RouteNotFoundException $e) {
      $form_state
        ->setError($form['redirect_override_routes'], $e
        ->getMessage());
    }
  }
}