You are here

public function ResponsiveFaviconsAdmin::validateForm in Responsive Favicons 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/ResponsiveFaviconsAdmin.php, line 126

Class

ResponsiveFaviconsAdmin
Class ResponsiveFaviconsAdmin.

Namespace

Drupal\responsive_favicons\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $path_type = $form_state
    ->getValue('path_type');
  if ($path_type === 'path') {
    $path = rtrim($form_state
      ->getValue('local_path'));
    if (!is_dir(DRUPAL_ROOT . $path)) {
      $form_state
        ->setErrorByName('local_path', $this
        ->t('The directory %dir does not exist.', [
        '%dir' => $path,
      ]));
    }
  }
}