You are here

public function ContentHubEntityTypeConfig::calculateDependencies in Acquia Content Hub 8

Calculates dependencies and stores them in the dependency property.

Return value

$this

Overrides ConfigEntityBase::calculateDependencies

See also

\Drupal\Core\Config\Entity\ConfigDependencyManager

File

src/Entity/ContentHubEntityTypeConfig.php, line 166

Class

ContentHubEntityTypeConfig
Defines a ContentHubEntityTypeConfig configuration entity class.

Namespace

Drupal\acquia_contenthub\Entity

Code

public function calculateDependencies() {
  parent::calculateDependencies();

  // Add dependencies on module.
  $entity_type = $this
    ->entityTypeManager()
    ->getDefinition($this
    ->id());
  $this
    ->addDependency('module', $entity_type
    ->getProvider());

  // Add config dependencies.
  $bundles = array_keys($this
    ->getBundles());
  foreach ($bundles as $bundle) {
    if ($this
      ->isEnableIndex($bundle)) {

      // Add dependency on this particular bundle.
      $this
        ->calculateDependenciesForBundle($entity_type, $bundle);

      // Add dependencies on all enabled view modes.
      if ($this
        ->isEnabledViewModes($bundle)) {
        $this
          ->calculateDependenciesForViewModes($entity_type, $bundle);
      }

      // Add dependencies on preview image fields and styles.
      $entity_field_manager = $this
        ->entityFieldManager();
      $this
        ->calculateDependenciesForPreviewImage($entity_field_manager, $bundle);
    }
  }
  return $this;
}