public function CircleCiFrontendEnvironment::getAdditionalDeployFormElements in Build Hooks 3.x
Same name and namespace in other branches
- 8.2 modules/build_hooks_circleci/src/Plugin/FrontendEnvironment/CircleCiFrontendEnvironment.php \Drupal\build_hooks_circleci\Plugin\FrontendEnvironment\CircleCiFrontendEnvironment::getAdditionalDeployFormElements()
Allows the plugin to add elements to the deployment form.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
Return value
array A form array to add to the deployment form.
Overrides FrontendEnvironmentInterface::getAdditionalDeployFormElements
File
- modules/
build_hooks_circleci/ src/ Plugin/ FrontendEnvironment/ CircleCiFrontendEnvironment.php, line 110
Class
- CircleCiFrontendEnvironment
- Provides a 'CircleCI' frontend environment type.
Namespace
Drupal\build_hooks_circleci\Plugin\FrontendEnvironmentCode
public function getAdditionalDeployFormElements(FormStateInterface $form_state) {
// This plugin adds to the deployment form a fieldset displaying the
// latest deployments:
$form = [];
$form['latestCircleCiDeployments'] = [
'#type' => 'details',
'#title' => $this
->t('Recent deployments'),
'#description' => $this
->t('Here you can see the details for the latest deployments for this environment.'),
'#open' => TRUE,
];
try {
$form['latestCircleCiDeployments']['table'] = $this
->getLastCircleCiDeploymentsTable($this
->getConfiguration());
$form['latestCircleCiDeployments']['refresher'] = [
'#type' => 'button',
'#ajax' => [
'callback' => [
CircleCiFrontendEnvironment::class,
'refreshDeploymentTable',
],
'wrapper' => 'ajax-replace-table',
'effect' => 'fade',
'progress' => [
'type' => 'throbber',
'message' => $this
->t('Refreshing deployment status...'),
],
],
'#value' => $this
->t('Refresh'),
];
} catch (GuzzleException $e) {
$this
->messenger()
->addError('Unable to retrieve information about the last deployments for this environment. Check configuration.');
}
return $form;
}