public function WebhookDeleteConfirmForm::buildForm in Acquia Content Hub 8.2
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- modules/
acquia_contenthub_publisher/ src/ Form/ Webhook/ WebhookDeleteConfirmForm.php, line 80
Class
- WebhookDeleteConfirmForm
- Confirmation form for webhook deletion.
Namespace
Drupal\acquia_contenthub_publisher\Form\WebhookCode
public function buildForm(array $form, FormStateInterface $form_state, $uuid = NULL) {
$this->uuid = $uuid;
$this->event = new AcquiaContentHubUnregisterEvent($this->uuid, '', TRUE);
$this->dispatcher
->dispatch(AcquiaContentHubEvents::ACH_UNREGISTER, $this->event);
$form['cancel'] = [
'#type' => 'submit',
'#value' => $this
->t('Cancel'),
'#button_type' => 'primary',
'#name' => 'cancel',
'#weight' => 101,
];
$orphaned_filters = $this->event
->getOrphanedFilters();
if (!empty($orphaned_filters)) {
$form['filters'] = [
'#type' => 'details',
'#title' => $this
->t('With webhook deletion the following filters will be deleted as well:'),
'#open' => TRUE,
'#weight' => -1,
];
$form['filters']['orphaned_filters'] = [
'#type' => 'table',
'#title' => $this
->t('Filters'),
'#header' => [
'Filter name',
'Filter UUID',
],
'#rows' => $this
->formatOrphanedFiltersTable($orphaned_filters),
];
$form['actions']['delete_webhook_and_filters'] = [
'#type' => 'submit',
'#submit' => [
[
$this,
'deleteFilters',
],
[
$this,
'deleteWebhook',
],
],
'#value' => $this
->t('Delete webhook and filters'),
'#button_type' => 'primary',
'#weight' => 100,
'#limit_validation_errors' => [],
];
if ($this
->checkDiscoveryRoute()) {
$form['actions']['redirect'] = [
'#type' => 'link',
'#title' => $this
->t('Go to Discovery Interface'),
'#url' => Url::fromRoute('acquia_contenthub_curation.discovery'),
'#weight' => 99,
'#attributes' => [
'class' => [
'button',
],
],
];
}
return $form;
}
$this
->messenger()
->addStatus('Everything is in order, safe to proceed!');
$form['actions']['delete_webhook'] = [
'#type' => 'submit',
'#submit' => [
[
$this,
'deleteFilters',
],
[
$this,
'deleteWebhook',
],
],
'#value' => $this
->t('Delete webhook'),
'#button_type' => 'primary',
];
return $form;
}