private function CircleCiFrontendEnvironment::getLastCircleCiDeploymentsTable 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::getLastCircleCiDeploymentsTable()
Gets info about the latest circle ci deployments for this environment.
Parameters
array $settings: The plugin settings array.
Return value
array Renderable array.
Throws
\GuzzleHttp\Exception\GuzzleException
1 call to CircleCiFrontendEnvironment::getLastCircleCiDeploymentsTable()
- CircleCiFrontendEnvironment::getAdditionalDeployFormElements in modules/
build_hooks_circleci/ src/ Plugin/ FrontendEnvironment/ CircleCiFrontendEnvironment.php - Allows the plugin to add elements to the deployment form.
File
- modules/
build_hooks_circleci/ src/ Plugin/ FrontendEnvironment/ CircleCiFrontendEnvironment.php, line 161
Class
- CircleCiFrontendEnvironment
- Provides a 'CircleCI' frontend environment type.
Namespace
Drupal\build_hooks_circleci\Plugin\FrontendEnvironmentCode
private function getLastCircleCiDeploymentsTable(array $settings) {
$circleCiData = $this->circleCiManager
->retrieveLatestBuildsFromCircleciForEnvironment($settings, 8);
$element = [
'#type' => 'table',
'#attributes' => [
'id' => 'ajax-replace-table',
],
'#header' => [
$this
->t('Status'),
$this
->t('Started at'),
$this
->t('Finished at'),
],
];
if (!empty($circleCiData)) {
foreach ($circleCiData as $circleCiDeployment) {
// @todo HACK: We do not want to show the "validate" jobs:
if ($circleCiDeployment['build_parameters']['CIRCLE_JOB'] == 'validate') {
continue;
}
$element[$circleCiDeployment['build_num']]['status'] = [
'#type' => 'item',
'#markup' => '<strong>' . $circleCiDeployment['status'] . '</strong>',
];
$started_time = $circleCiDeployment['start_time'] ? $this->circleCiManager
->formatCircleCiDateTime($circleCiDeployment['start_time']) : '';
$element[$circleCiDeployment['build_num']]['started_at'] = [
'#type' => 'item',
'#markup' => $started_time,
];
$stopped_time = $circleCiDeployment['stop_time'] ? $this->circleCiManager
->formatCircleCiDateTime($circleCiDeployment['stop_time']) : '';
$element[$circleCiDeployment['build_num']]['finished_at'] = [
'#type' => 'item',
'#markup' => $stopped_time,
];
}
}
return $element;
}