You are here

public function ContentHubSettingsForm::updateWebhook in Acquia Content Hub 8.2

Updates webhook.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Throws

\Exception

File

src/Form/ContentHubSettingsForm.php, line 422

Class

ContentHubSettingsForm
Defines the form to configure the Content Hub connection settings.

Namespace

Drupal\acquia_contenthub\Form

Code

public function updateWebhook(array &$form, FormStateInterface $form_state) : void {
  $webhook_url = $this
    ->getFormattedWebhookUrl($form_state);
  $response = [];
  try {
    $response = $this->chConnectionManager
      ->checkClient()
      ->updateWebhook($webhook_url);
  } catch (\Exception $e) {
    $this
      ->logger('acquia_contenthub')
      ->warning($e);
  }
  if (!$response) {
    $this
      ->messenger()
      ->addError($this
      ->t("Something went wrong during webhook (%webhook) update. Check logs for more information.", [
      '%webhook' => $webhook_url,
    ]));
    return;
  }
  $this
    ->messenger()
    ->addMessage($this
    ->t('Successfully Updated Public URL.'));
}