public function SearchFileAttachmentsSettingsForm::validateForm in Search File Attachments 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/ SearchFileAttachmentsSettingsForm.php, line 107
Class
- SearchFileAttachmentsSettingsForm
- Configure search file attachments settings.
Namespace
Drupal\search_file_attachments\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$tika_path = rtrim($form_state
->getValue('search_file_attachments_tika_path'), '/');
$tika_path = realpath($tika_path);
if (!file_exists($tika_path . '/' . $form_state
->getValue('search_file_attachments_tika_jar'))) {
$form_state
->setErrorByName('search_file_attachments_tika_path', $this
->t('Tika jar file not found at this path.'));
}
$java_path = $form_state
->getValue('search_file_attachments_java_path');
$this->javaService
->setJavaPath($java_path);
if (!empty($java_path) && !$this->javaService
->checkJava()) {
$form_state
->setErrorByName('search_file_attachments_java_path', $this
->t('Java was not found or is executable at the specified path.'));
}
parent::validateForm($form, $form_state);
}