You are here

public function DeployLogger::logEntityDeleted in Build Hooks 8.2

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

Logs the deleting of an entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

File

src/DeployLogger.php, line 117

Class

DeployLogger
Class DeployLogger.

Namespace

Drupal\build_hooks

Code

public function logEntityDeleted(ContentEntityInterface $entity) {

  /** @var \Drupal\build_hooks\DeploymentStorageHandlerInterface $deployment_storage */
  $deployment_storage = $this->entityTypeManager
    ->getStorage('build_hooks_deployment');
  foreach ($this->entityTypeManager
    ->getStorage('frontend_environment')
    ->loadMultiple() as $environment) {
    $deployment = $deployment_storage
      ->getOrCreateNextDeploymentForEnvironment($environment);
    $deployment->deleted[] = sprintf('%s (%s)', $entity
      ->label(), $this->entityTypeManager
      ->getDefinition($entity
      ->getEntityTypeId())
      ->getLabel());
    $deployment
      ->save();
  }
}