You are here

protected function ContentHubEntityTypeConfig::calculateDependenciesForViewModes in Acquia Content Hub 8

Calculate dependencies for view modes.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The Entity Type object.

string $bundle: The entity bundle.

1 call to ContentHubEntityTypeConfig::calculateDependenciesForViewModes()
ContentHubEntityTypeConfig::calculateDependencies in src/Entity/ContentHubEntityTypeConfig.php
Calculates dependencies and stores them in the dependency property.

File

src/Entity/ContentHubEntityTypeConfig.php, line 215

Class

ContentHubEntityTypeConfig
Defines a ContentHubEntityTypeConfig configuration entity class.

Namespace

Drupal\acquia_contenthub\Entity

Code

protected function calculateDependenciesForViewModes(EntityTypeInterface $entity_type, $bundle) {
  if ($this
    ->isEnabledViewModes($bundle)) {
    $view_modes = $this
      ->getRenderingViewModes($bundle);
    foreach ($view_modes as $view_mode) {

      // Enable dependency on these view modes.

      /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
      $viewmode = "{$entity_type->id()}.{$bundle}.{$view_mode}";
      if ($display = EntityViewDisplay::load($viewmode)) {
        $this
          ->addDependencies($display
          ->getDependencies());
      }
    }
  }
}