public function BitbucketFrontendEnvironment::getAdditionalDeployFormElements in Build Hooks 3.x
Same name and namespace in other branches
- 8.2 modules/build_hooks_bitbucket/src/Plugin/FrontendEnvironment/BitbucketFrontendEnvironment.php \Drupal\build_hooks_bitbucket\Plugin\FrontendEnvironment\BitbucketFrontendEnvironment::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_bitbucket/ src/ Plugin/ FrontendEnvironment/ BitbucketFrontendEnvironment.php, line 154
Class
- BitbucketFrontendEnvironment
- Provides a 'Bitbucket pipelines' frontend environment type.
Namespace
Drupal\build_hooks_bitbucket\Plugin\FrontendEnvironmentCode
public function getAdditionalDeployFormElements(FormStateInterface $form_state) {
// This plugin adds to the deployment form a fieldset displaying the
// latest deployments:
$form = [];
$form['bitbucketDeployments'] = [
'#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['bitbucketDeployments']['table'] = $this
->getLastBitbucketDeploymentsTable($this
->getConfiguration());
$form['bitbucketDeployments']['refresher'] = [
'#type' => 'button',
'#ajax' => [
'callback' => [
self::class,
'refreshDeploymentTable',
],
'wrapper' => 'ajax-replace-table',
'effect' => 'fade',
'progress' => [
'type' => 'throbber',
'message' => $this
->t('Refreshing deployment status...'),
],
],
'#value' => $this
->t('Refresh'),
];
} catch (\Exception $e) {
$this
->messenger()
->addError('Unable to retrieve information about the last deployments for this environment. Check configuration.')
->addError($e
->getMessage());
}
return $form;
}