You are here

public function EmbedBase::trackOnEntityCreation in Entity Usage 8

Track usage updates on the creation of entities.

Parameters

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

Overrides EntityUsageTrackBase::trackOnEntityCreation

File

src/Plugin/EntityUsage/Track/EmbedBase.php, line 78

Class

EmbedBase
Base class for plugins tracking usage in entities embedded in WYSIWYG fields.

Namespace

Drupal\entity_usage\Plugin\EntityUsage\Track

Code

public function trackOnEntityCreation(ContentEntityInterface $entity) {
  $referenced_entities_by_field = $this
    ->getEmbeddedEntitiesByField($entity);
  foreach ($referenced_entities_by_field as $field => $embedded_entities) {
    foreach ($embedded_entities as $uuid => $type) {

      // Increment the usage as embedded entity.
      $this
        ->incrementEmbeddedUsage($entity, $type, $uuid);
    }
  }
}