private function NetlifyFrontendEnvironment::getLastNetlifyDeploymentsTable in Build Hooks 3.x
Same name and namespace in other branches
- 8.2 modules/build_hooks_netlify/src/Plugin/FrontendEnvironment/NetlifyFrontendEnvironment.php \Drupal\build_hooks_netlify\Plugin\FrontendEnvironment\NetlifyFrontendEnvironment::getLastNetlifyDeploymentsTable()
Displays info about the latest netlify deployments for this environment.
Parameters
array $settings: The plugin settings array.
Return value
array Renderable array.
Throws
\GuzzleHttp\Exception\GuzzleException
1 call to NetlifyFrontendEnvironment::getLastNetlifyDeploymentsTable()
- NetlifyFrontendEnvironment::getAdditionalDeployFormElements in modules/
build_hooks_netlify/ src/ Plugin/ FrontendEnvironment/ NetlifyFrontendEnvironment.php - Allows the plugin to add elements to the deployment form.
File
- modules/
build_hooks_netlify/ src/ Plugin/ FrontendEnvironment/ NetlifyFrontendEnvironment.php, line 176
Class
- NetlifyFrontendEnvironment
- Provides a 'Netlify' frontend environment type.
Namespace
Drupal\build_hooks_netlify\Plugin\FrontendEnvironmentCode
private function getLastNetlifyDeploymentsTable(array $settings) {
$netlifyData = $this->netlifyManager
->retrieveLatestBuildsFromNetlifyForEnvironment($settings, 8);
$element = [
'#type' => 'table',
'#attributes' => [
'id' => 'ajax-replace-table',
],
'#header' => [
$this
->t('Status'),
$this
->t('Started at'),
$this
->t('Finished at'),
$this
->t('Message'),
],
];
if (!empty($netlifyData)) {
foreach ($netlifyData as $netlifyDeployment) {
$element[$netlifyDeployment['id']]['status'] = [
'#type' => 'item',
'#markup' => '<strong>' . $netlifyDeployment['state'] . '</strong>',
];
$started_time = $netlifyDeployment['created_at'] ? $this->netlifyManager
->formatNetlifyDateTime($netlifyDeployment['created_at']) : '';
$element[$netlifyDeployment['id']]['started_at'] = [
'#type' => 'item',
'#markup' => $started_time,
];
$stopped_time = $netlifyDeployment['published_at'] ? $this->netlifyManager
->formatNetlifyDateTime($netlifyDeployment['published_at']) : '';
$element[$netlifyDeployment['id']]['finished_at'] = [
'#type' => 'item',
'#markup' => $stopped_time,
];
$message = $netlifyDeployment['error_message'] ? $netlifyDeployment['error_message'] : '';
$element[$netlifyDeployment['id']]['error_message'] = [
'#type' => 'item',
'#markup' => $message,
];
}
}
return $element;
}