public function EntityType::getBundleConfigDependency in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleConfigDependency()
- 9 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleConfigDependency()
Gets the config dependency info for this entity, if any exists.
Parameters
string $bundle: The bundle name.
Return value
array An associative array containing the following keys:
- 'type': The config dependency type (e.g. 'module', 'config').
- 'name': The name of the config dependency.
Overrides EntityTypeInterface::getBundleConfigDependency
File
- core/
lib/ Drupal/ Core/ Entity/ EntityType.php, line 864
Class
- EntityType
- Provides an implementation of an entity type and its metadata.
Namespace
Drupal\Core\EntityCode
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;
}