function ContentEntityStorageBase::getBundleFromClass
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getBundleFromClass()
- 10 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getBundleFromClass()
Overrides BundleEntityStorageInterface::getBundleFromClass
File
-
core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php, line 136
Class
- ContentEntityStorageBase
- Base class for content entity storage handlers.
Namespace
Drupal\Core\EntityCode
public function getBundleFromClass(string $class_name) : ?string {
$bundle_for_class = NULL;
foreach ($this->entityTypeBundleInfo
->getBundleInfo($this->entityTypeId) as $bundle => $bundle_info) {
if (!empty($bundle_info['class']) && $bundle_info['class'] === $class_name) {
if ($bundle_for_class) {
throw new AmbiguousBundleClassException($class_name);
}
else {
$bundle_for_class = $bundle;
}
}
}
return $bundle_for_class;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.