public function WebhookAddForm::submitForm in Acquia Content Hub 8.2
Throws
\Exception
Overrides FormInterface::submitForm
File
- modules/
acquia_contenthub_publisher/ src/ Form/ Webhook/ WebhookAddForm.php, line 54
Class
- WebhookAddForm
- Class WebhookAddForm.
Namespace
Drupal\acquia_contenthub_publisher\Form\WebhookCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->setRedirect('acquia_contenthub.subscription_settings');
$url = trim($form_state
->getValue('url'));
$response = $this->client
->addWebhook($url);
if (empty($response) || empty($response['success'])) {
$this
->messenger()
->addError($this
->t('Unable to add webhook %url. Error %code: %message', [
'%url' => $url,
'%code' => $response['error']['code'] ?? $this
->t('n/a'),
'%message' => $response['error']['message'] ?? $this
->t('n/a'),
]));
return;
}
$this
->messenger()
->addStatus($this
->t('Webhook %url has been added.', [
'%url' => $url,
]));
}