public function FileTransferAuthorizeForm::validateForm in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php \Drupal\Core\FileTransfer\Form\FileTransferAuthorizeForm::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
- core/
lib/ Drupal/ Core/ FileTransfer/ Form/ FileTransferAuthorizeForm.php, line 163 - Contains \Drupal\Core\FileTransfer\Form\FileTransferAuthorizeForm.
Class
- FileTransferAuthorizeForm
- Provides the file transfer authorization form.
Namespace
Drupal\Core\FileTransfer\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Only validate the form if we have collected all of the user input and are
// ready to proceed with updating or installing.
if ($form_state
->getTriggeringElement()['#name'] != 'process_updates') {
return;
}
if ($form_connection_settings = $form_state
->getValue('connection_settings')) {
$backend = $form_connection_settings['authorize_filetransfer_default'];
$filetransfer = $this
->getFiletransfer($backend, $form_connection_settings[$backend]);
try {
if (!$filetransfer) {
throw new \Exception($this
->t('The connection protocol %backend does not exist.', array(
'%backend' => $backend,
)));
}
$filetransfer
->connect();
} catch (\Exception $e) {
// The format of this error message is similar to that used on the
// database connection form in the installer.
$form_state
->setErrorByName('connection_settings', $this
->t('Failed to connect to the server. The server reports the following message: <p class="error">@message</p> For more help installing or updating code on your server, see the <a href=":handbook_url">handbook</a>.', array(
'@message' => $e
->getMessage(),
':handbook_url' => 'https://www.drupal.org/documentation/install/modules-themes',
)));
}
}
}