You are here

class FocalPointCollector in Acquia Content Hub 8.2

Add focal point dependencies.

@package Drupal\acquia_contenthub\EventSubscriber\DependencyCollector

Hierarchy

Expanded class hierarchy of FocalPointCollector

1 string reference to 'FocalPointCollector'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses FocalPointCollector
acquia_contenthub.focal_point.collector in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\DependencyCollector\FocalPointCollector

File

src/EventSubscriber/DependencyCollector/FocalPointCollector.php, line 15

Namespace

Drupal\acquia_contenthub\EventSubscriber\DependencyCollector
View source
class FocalPointCollector extends EmbeddedImagesCollector {

  /**
   * Reacts on CALCULATE_DEPENDENCIES event.
   *
   * @param \Drupal\depcalc\Event\CalculateEntityDependenciesEvent $event
   *   Event.
   *
   * @throws \Exception
   */
  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);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BaseDependencyCollector::getCalculator protected function Gets the dependency calculator.
BaseDependencyCollector::mergeDependencies protected function Properly adds dependencies and their modules to a wrapper object.
EmbeddedImagesCollector::$database protected property Database connection.
EmbeddedImagesCollector::$moduleHandler protected property The module handler.
EmbeddedImagesCollector::addDependency protected function Add dependency.
EmbeddedImagesCollector::getAttachedFiles protected function Builds list of attached files.
EmbeddedImagesCollector::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
EmbeddedImagesCollector::__construct public function EmbeddedImagesCollector constructor.
FocalPointCollector::onCalculateDependencies public function Reacts on CALCULATE_DEPENDENCIES event. Overrides EmbeddedImagesCollector::onCalculateDependencies