public function SamlSpConfig::validateForm in SAML Service Provider 3.x
Same name and namespace in other branches
- 8.3 src/Form/SamlSpConfig.php \Drupal\saml_sp\Form\SamlSpConfig::validateForm()
- 8.2 src/Form/SamlSpConfig.php \Drupal\saml_sp\Form\SamlSpConfig::validateForm()
- 4.x src/Form/SamlSpConfig.php \Drupal\saml_sp\Form\SamlSpConfig::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
- src/
Form/ SamlSpConfig.php, line 101
Class
- SamlSpConfig
- Provides the configuration form.
Namespace
Drupal\saml_sp\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Ensure the cert and key files are provided and exist in the system if
// signed or encryption options require them.
$values = $form_state
->getValues();
if ($values['security']['authnRequestsSigned'] || $values['security']['logoutRequestSigned'] || $values['security']['logoutResponseSigned'] || $values['security']['wantNameIdEncrypted'] || $values['security']['signMetaData']) {
foreach ([
'key_location',
'cert_location',
] as $key) {
if (empty($values[$key])) {
$form_state
->setError($form[$key], $this
->t('The %field must be provided.', [
'%field' => $form[$key]['#title'],
]));
}
elseif (!file_exists($values[$key])) {
$form_state
->setError($form[$key], $this
->t('The %input file does not exist.', [
'%input' => $values[$key],
]));
}
}
}
}