You are here

public function S3StorageHandlerModuleDependencyCollector::onCalculateDependencies in Acquia Content Hub 8.2

Adds the accepted s3 modules to the module dependency list if applicable.

Parameters

\Drupal\depcalc\Event\CalculateEntityDependenciesEvent $event: The dependency calculation event.

File

modules/acquia_contenthub_s3/src/EventSubscriber/DependencyCollector/S3StorageHandlerModuleDependencyCollector.php, line 55

Class

S3StorageHandlerModuleDependencyCollector
Subscribes to dependency collection to append module dependency information.

Namespace

Drupal\acquia_contenthub_s3\EventSubscriber\DependencyCollector

Code

public function onCalculateDependencies(CalculateEntityDependenciesEvent $event) {

  /** @var \Drupal\field\FieldStorageConfigInterface $entity */
  $entity = $event
    ->getEntity();
  if ($entity
    ->getEntityTypeId() !== 'field_storage_config') {
    return;
  }
  $uri_scheme = $entity
    ->getSetting('uri_scheme');
  if (!$uri_scheme || $uri_scheme !== 's3') {
    return;
  }
  $modules = $this
    ->getS3ModuleDependencies();
  if (empty($modules)) {
    return;
  }
  $modules = array_merge($event
    ->getModuleDependencies(), $modules);
  $event
    ->setModuleDependencies($modules);
}