You are here

public function DeployLogger::getNumberOfItemsSinceLastDeploymentForEnvironment in Build Hooks 8.2

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

Gets how many changes have happened since the last deployment for an env.

Parameters

\Drupal\build_hooks\Entity\FrontendEnvironment $environment: The frontend environment config entity.

Return value

int The amount of changes for the environment since last deployment.

File

src/DeployLogger.php, line 185

Class

DeployLogger
Class DeployLogger.

Namespace

Drupal\build_hooks

Code

public function getNumberOfItemsSinceLastDeploymentForEnvironment(FrontendEnvironment $environment) {

  /** @var \Drupal\build_hooks\DeploymentStorageHandlerInterface $deployment_storage */
  $deployment_storage = $this->entityTypeManager
    ->getStorage('build_hooks_deployment');
  $next = $deployment_storage
    ->getOrCreateNextDeploymentForEnvironment($environment);
  return count(array_filter(iterator_to_array($next
    ->get('contents')), function (DynamicEntityReferenceItem $item) {

    // Filter out since deleted items.
    return $item->entity;
  })) + $next
    ->get('deleted')
    ->count();
}