public function ExportAllForm::validateForm in Bibliography & Citation 2.0.x
Same name and namespace in other branches
- 8 modules/bibcite_export/src/Form/ExportAllForm.php \Drupal\bibcite_export\Form\ExportAllForm::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
- modules/
bibcite_export/ src/ Form/ ExportAllForm.php, line 160
Class
- ExportAllForm
- Export all reference data to any available export format.
Namespace
Drupal\bibcite_export\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$format = $this->formatManager
->hasDefinition($form_state
->getValue('format'));
if (!isset($format)) {
$form_state
->setErrorByName('format', $this
->t('Trying export to non-existing format.'));
}
$storage = \Drupal::entityTypeManager()
->getStorage('bibcite_reference');
$total = $storage
->getQuery()
->count()
->execute();
if (!$total) {
$form_state
->setError($form, $this
->t('There is no data to export.'));
}
}