You are here

public function TcaSettings::calculateDependencies in Token Content Access 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/TcaSettings.php \Drupal\tca\Entity\TcaSettings::calculateDependencies()

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/TcaSettings.php, line 130

Class

TcaSettings
Defines the TCA settings entity.

Namespace

Drupal\tca\Entity

Code

public function calculateDependencies() {
  parent::calculateDependencies();
  if ($this->entity_type_id && $this->entity_id) {

    // Create dependency on the bundle.
    $entity_type_manager = \Drupal::entityTypeManager();
    $entity = $entity_type_manager
      ->getStorage($this->entity_type_id)
      ->load($this->entity_id);
    $bundle = $entity_type_manager
      ->getDefinition($this->entity_type_id);
    $entity_type = $entity_type_manager
      ->getDefinition($bundle
      ->getBundleOf() ?: $this->entity_type_id);
    $bundle_name = $entity
      ->getEntityType()
      ->getBundleEntityType() ? $entity
      ->bundle() : $this->entity_id;
    $bundle_config_dependency = $entity_type
      ->getBundleConfigDependency($bundle_name);
    $this
      ->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']);
  }
  return $this;
}