public function EntityUsageTrackBase::trackOnEntityCreation in Entity Usage 8.3
Same name and namespace in other branches
- 8 src/EntityUsageTrackBase.php \Drupal\entity_usage\EntityUsageTrackBase::trackOnEntityCreation()
- 8.2 src/EntityUsageTrackBase.php \Drupal\entity_usage\EntityUsageTrackBase::trackOnEntityCreation()
Track usage updates on the creation of entities.
Parameters
\Drupal\Core\Entity\EntityInterface $source_entity: The source entity.
Overrides EntityUsageTrackInterface::trackOnEntityCreation
File
- src/
EntityUsageTrackBase.php, line 140
Class
- EntityUsageTrackBase
- Base implementation for track plugins.
Namespace
Drupal\entity_usageCode
public function trackOnEntityCreation(EntityInterface $top_entity) {
if (!$this
->isApplicable($top_entity)) {
return;
}
$targets = $this
->getAllBottomLevelTargets($top_entity);
$top_vid = $top_entity instanceof RevisionableInterface && $top_entity
->getRevisionId() ? $top_entity
->getRevisionId() : 0;
foreach ($targets as $target_type_and_id) {
list($target_type, $target_id) = explode("|", $target_type_and_id);
$this->usageService
->registerUsage($target_id, $target_type, $top_entity
->id(), $top_entity
->getEntityTypeId(), $top_entity
->language()
->getId(), $top_vid);
}
}