You are here

public function DeploymentStorageHandler::getLastDeploymentForEnvironment in Build Hooks 8.2

Same name and namespace in other branches
  1. 3.x src/DeploymentStorageHandler.php \Drupal\build_hooks\DeploymentStorageHandler::getLastDeploymentForEnvironment()

Gets the last deployment for an environment.

Parameters

\Drupal\build_hooks\Entity\FrontendEnvironmentInterface $environment: Environment.

Return value

\Drupal\build_hooks\Entity\DeploymentInterface|null Last deployment if it exists.

Overrides DeploymentStorageHandlerInterface::getLastDeploymentForEnvironment

1 call to DeploymentStorageHandler::getLastDeploymentForEnvironment()
DeploymentStorageHandler::getLabelForNextDeploymentForEnvironment in src/DeploymentStorageHandler.php
Gets the label for the next deployment.

File

src/DeploymentStorageHandler.php, line 59

Class

DeploymentStorageHandler
Defines a storage handler for Deployment entities.

Namespace

Drupal\build_hooks

Code

public function getLastDeploymentForEnvironment(FrontendEnvironmentInterface $environment) : ?DeploymentInterface {
  $ids = $this
    ->getQuery()
    ->condition('status', 1)
    ->condition('environment', $environment
    ->id())
    ->sort('deployed', 'DESC')
    ->range(0, 1)
    ->accessCheck(FALSE)
    ->execute();
  if ($ids) {
    return $this
      ->load(reset($ids));
  }
  return NULL;
}