public function DeployLogger::logEntityCreated in Build Hooks 8.2
Same name and namespace in other branches
- 3.x src/DeployLogger.php \Drupal\build_hooks\DeployLogger::logEntityCreated()
Logs the creation of an entity.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
1 call to DeployLogger::logEntityCreated()
- DeployLogger::logEntityUpdated in src/
DeployLogger.php - Logs the updating of an entity.
File
- src/
DeployLogger.php, line 86
Class
- DeployLogger
- Class DeployLogger.
Namespace
Drupal\build_hooksCode
public function logEntityCreated(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);
if (!$this
->entityAlreadyExistsInDeployment($deployment, $entity)) {
$deployment->contents[] = [
'target_id' => $entity
->id(),
'target_type' => $entity
->getEntityTypeId(),
];
$deployment
->save();
}
}
}