public function NetlifyManager::retrieveLatestBuildsFromNetlifyForEnvironment in Build Hooks 3.x
Same name and namespace in other branches
- 8.2 modules/build_hooks_netlify/src/NetlifyManager.php \Drupal\build_hooks_netlify\NetlifyManager::retrieveLatestBuildsFromNetlifyForEnvironment()
Get the latest builds from netlify for and environment.
Parameters
array $settings: The plugin settings array.
int $limit: Number of desired builds to retrieve.
Return value
array An array with info about the builds.
Throws
\GuzzleHttp\Exception\GuzzleException
Overrides NetlifyManagerInterface::retrieveLatestBuildsFromNetlifyForEnvironment
File
- modules/
build_hooks_netlify/ src/ NetlifyManager.php, line 60
Class
- NetlifyManager
- Defines a manager service for netlify deployments.
Namespace
Drupal\build_hooks_netlifyCode
public function retrieveLatestBuildsFromNetlifyForEnvironment(array $settings, $limit = 1) {
$url = $this
->buildNetlifyApiRetrieveBuildsUrl($settings);
$options = [
'headers' => [
'Accept' => 'application/json',
],
];
$response = $this->httpClient
->request('GET', $url, $options);
$payload = json_decode($response
->getBody()
->getContents(), TRUE);
// Since there is no way in the api to filter by branch,
// we do it by filtering the results:
$results = array_filter($payload, $this
->filterByBranch($settings['branch']));
return array_slice($results, 0, $limit);
}