public function WebhookEditForm::buildForm in Acquia Content Hub 8.2
Throws
\Exception
Overrides FormInterface::buildForm
File
- modules/
acquia_contenthub_publisher/ src/ Form/ Webhook/ WebhookEditForm.php, line 23
Class
- WebhookEditForm
- Class WebhookEditForm.
Namespace
Drupal\acquia_contenthub_publisher\Form\WebhookCode
public function buildForm(array $form, FormStateInterface $form_state, $uuid = NULL) {
$this->uuid = $uuid;
$webhooks = $this->client
->getWebHooks();
/** @var \Acquia\ContentHubClient\Webhook $webhook */
$webhook = current(array_filter($webhooks, function (Webhook $webhook) use ($uuid) {
return $webhook
->getUuid() === $uuid;
}));
if (!$webhook) {
$this
->messenger()
->addError($this
->t("Can't edit webhook %uuid. The webhook is not found.", [
'%uuid' => $uuid,
]));
return $this
->redirect('acquia_contenthub.subscription_settings');
}
$form['url'] = [
'#type' => 'textfield',
'#title' => $this
->t('Webhook URL'),
'#description' => $this
->t('Example: @url', [
'@url' => Url::fromRoute('acquia_contenthub.webhook', [], [
'absolute' => TRUE,
])
->toString(),
]),
'#required' => TRUE,
'#default_value' => $webhook
->getUrl(),
];
$form['submit'] = [
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => $this
->t('Save'),
];
return $form;
}