function EntityType::getBundleConfigDependency

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleConfigDependency()
  2. 10 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleConfigDependency()
  3. 11.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleConfigDependency()

Overrides EntityTypeInterface::getBundleConfigDependency

File

core/lib/Drupal/Core/Entity/EntityType.php, line 880

Class

EntityType
Provides an implementation of an entity type and its metadata.

Namespace

Drupal\Core\Entity

Code

public function getBundleConfigDependency($bundle) {
    // If this entity type uses entities to manage its bundles then depend on
    // the bundle entity.
    if ($bundle_entity_type_id = $this->getBundleEntityType()) {
        if (!($bundle_entity = \Drupal::entityTypeManager()->getStorage($bundle_entity_type_id)
            ->load($bundle))) {
            throw new \LogicException(sprintf('Missing bundle entity, entity type %s, entity id %s.', $bundle_entity_type_id, $bundle));
        }
        $config_dependency = [
            'type' => 'config',
            'name' => $bundle_entity->getConfigDependencyName(),
        ];
    }
    else {
        // Depend on the provider of the entity type.
        $config_dependency = [
            'type' => 'module',
            'name' => $this->getProvider(),
        ];
    }
    return $config_dependency;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.