function ContentEntityBase::getBundleEntity
Gets the bundle entity of this entity.
Return value
\Drupal\Core\Entity\EntityInterface|null The entity which is the bundle of this entity, or NULL if this entity's entity type does not represent bundles with an entity.
Overrides ContentEntityInterface::getBundleEntity
File
-
core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php, line 581
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\EntityCode
public function getBundleEntity() : ?EntityInterface {
$entityType = $this->getEntityType();
if (!$entityType->hasKey('bundle') || !$entityType->getBundleEntityType()) {
return NULL;
}
return $this->get($entityType->getKey('bundle'))->entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.