You are here

public function OAuthKeyForm::validateDestinationExists in Lightning API 8

Same name and namespace in other branches
  1. 8.4 src/Form/OAuthKeyForm.php \Drupal\lightning_api\Form\OAuthKeyForm::validateDestinationExists()
  2. 8.2 src/Form/OAuthKeyForm.php \Drupal\lightning_api\Form\OAuthKeyForm::validateDestinationExists()
  3. 8.3 src/Form/OAuthKeyForm.php \Drupal\lightning_api\Form\OAuthKeyForm::validateDestinationExists()

Ensures that the destination directory exists.

Parameters

array $element: The form element being validated.

FormStateInterface $form_state: The current form state.

File

src/Form/OAuthKeyForm.php, line 139

Class

OAuthKeyForm

Namespace

Drupal\lightning_api\Form

Code

public function validateDestinationExists(array &$element, FormStateInterface $form_state) {
  $dir = $element['#value'];
  if (is_dir($dir) == FALSE) {
    $form_state
      ->setError($element, $this
      ->t('%dir does not exist.', [
      '%dir' => $dir,
    ]));
  }
}