function ContentEntityForm::getBundleEntity

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::getBundleEntity()

Returns the bundle entity of the entity, or NULL if there is none.

Return value

\Drupal\Core\Entity\EntityInterface|null The bundle entity.

File

core/lib/Drupal/Core/Entity/ContentEntityForm.php, line 91

Class

ContentEntityForm
Entity form variant for content entity types.

Namespace

Drupal\Core\Entity

Code

protected function getBundleEntity() {
  if ($bundle_entity_type = $this->entity
    ->getEntityType()
    ->getBundleEntityType()) {
    return $this->entityTypeManager
      ->getStorage($bundle_entity_type)
      ->load($this->entity
      ->bundle());
  }
  return NULL;
}

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