public function EntityUpdateManager::trackUpdateOnCreation in Entity Usage 8.2
Same name and namespace in other branches
- 8 src/EntityUpdateManager.php \Drupal\entity_usage\EntityUpdateManager::trackUpdateOnCreation()
- 8.3 src/EntityUpdateManager.php \Drupal\entity_usage\EntityUpdateManager::trackUpdateOnCreation()
Track updates on creation of potential source entities.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity we are dealing with.
File
- src/
EntityUpdateManager.php, line 60
Class
- EntityUpdateManager
- Class EntityUpdateManager.
Namespace
Drupal\entity_usageCode
public function trackUpdateOnCreation(EntityInterface $entity) {
if (!$this
->allowSourceEntityTracking($entity)) {
return;
}
// Call all plugins that want to track entity usages. We need to call this
// for all translations as well since Drupal stores new revisions for all
// translations by default when saving an entity.
if ($entity instanceof TranslatableInterface) {
foreach ($entity
->getTranslationLanguages() as $translation_language) {
if ($entity
->hasTranslation($translation_language
->getId())) {
/** @var \Drupal\Core\Entity\EntityInterface $translation */
$translation = $entity
->getTranslation($translation_language
->getId());
foreach ($this
->getEnabledPlugins() as $plugin) {
$plugin
->trackOnEntityCreation($translation);
}
}
}
}
else {
// Not translatable, just call the plugins with the entity itself.
foreach ($this
->getEnabledPlugins() as $plugin) {
$plugin
->trackOnEntityCreation($entity);
}
}
}