You are here

public function EntityUpdateManager::trackUpdateOnCreation in Entity Usage 8

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

Track updates on creation of potential host entities.

Parameters

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

File

src/EntityUpdateManager.php, line 50

Class

EntityUpdateManager
Class EntityUpdateManager.

Namespace

Drupal\entity_usage

Code

public function trackUpdateOnCreation(ContentEntityInterface $entity) {

  // Only act on content entities.
  if (!$entity instanceof ContentEntityInterface) {
    return;
  }

  // Call all plugins that want to track entity usages.
  foreach ($this->trackManager
    ->getDefinitions() as $plugin_id => $plugin_definition) {

    /** @var EntityUsageTrackInterface $instance */
    $instance = $this->trackManager
      ->createInstance($plugin_id);
    $instance
      ->trackOnEntityCreation($entity);
  }
}