You are here

protected function EntityUpdateManager::trackUpdateOnEdition in Entity Usage 8.3

Same name and namespace in other branches
  1. 8 src/EntityUpdateManager.php \Drupal\entity_usage\EntityUpdateManager::trackUpdateOnEdition()
  2. 8.2 src/EntityUpdateManager.php \Drupal\entity_usage\EntityUpdateManager::trackUpdateOnEdition()

Track updates on edit / update of potential source entities.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity we are dealing with.

1 call to EntityUpdateManager::trackUpdateOnEdition()
EntityUpdateManager::destruct in src/EntityUpdateManager.php
Performs destruct operations.

File

src/EntityUpdateManager.php, line 217

Class

EntityUpdateManager
Class EntityUpdateManager.

Namespace

Drupal\entity_usage

Code

protected function trackUpdateOnEdition(EntityInterface $entity, EntityInterface $original) {
  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\ContentEntityInterface $translation */
        $translation = $entity
          ->getTranslation($translation_language
          ->getId());
        foreach ($this
          ->getEnabledPlugins() as $plugin) {
          $plugin
            ->trackOnEntityUpdate($translation, $original);
        }
      }
    }
  }
  else {

    // Not translatable, just call the plugins with the entity itself.
    foreach ($this
      ->getEnabledPlugins() as $plugin) {
      $plugin
        ->trackOnEntityUpdate($entity, $original);
    }
  }
}