public function EmbeddedImagesCollector::onCalculateDependencies in Dependency Calculation 8
Reacts on CALCULATE_DEPENDENCIES event.
Parameters
\Drupal\depcalc\Event\CalculateEntityDependenciesEvent $event: Event.
Throws
\Exception
File
- src/
EventSubscriber/ DependencyCollector/ EmbeddedImagesCollector.php, line 65
Class
- EmbeddedImagesCollector
- Class EmbeddedImagesCollector.
Namespace
Drupal\depcalc\EventSubscriber\DependencyCollectorCode
public function onCalculateDependencies(CalculateEntityDependenciesEvent $event) {
if (!$this->moduleHandler
->moduleExists('file')) {
return;
}
$entity = $event
->getEntity();
if (FALSE === $entity instanceof ContentEntityInterface) {
return;
}
$files = $this
->getAttachedFiles($entity, 'editor');
foreach ($files as $file) {
$this
->addDependency($event, $file);
}
}