public function FocalPointCollector::onCalculateDependencies in Acquia Content Hub 8.2
Reacts on CALCULATE_DEPENDENCIES event.
Parameters
\Drupal\depcalc\Event\CalculateEntityDependenciesEvent $event: Event.
Throws
\Exception
Overrides EmbeddedImagesCollector::onCalculateDependencies
File
- src/
EventSubscriber/ DependencyCollector/ FocalPointCollector.php, line 25
Class
- FocalPointCollector
- Add focal point dependencies.
Namespace
Drupal\acquia_contenthub\EventSubscriber\DependencyCollectorCode
public function onCalculateDependencies(CalculateEntityDependenciesEvent $event) {
if (!$this->moduleHandler
->moduleExists('focal_point')) {
return;
}
elseif (!$this->moduleHandler
->moduleExists('file')) {
return;
}
$entity = $event
->getEntity();
if (FALSE === $entity instanceof ContentEntityInterface) {
return;
}
$files = $this
->getAttachedFiles($entity);
foreach ($files as $file) {
$find_crop = Crop::findCrop($file
->getFileUri(), 'focal_point');
if ($find_crop) {
$crop = Crop::load($find_crop
->id());
$this
->addDependency($event, $crop);
}
}
}