function ContentEntityForm::getBundleEntity

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::getBundleEntity()
  2. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::getBundleEntity()
  3. 10 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.

2 calls to ContentEntityForm::getBundleEntity()
BlockContentForm::save in core/modules/block_content/src/BlockContentForm.php
Form submission handler for the 'save' action.
ContentEntityForm::getNewRevisionDefault in core/lib/Drupal/Core/Entity/ContentEntityForm.php
Should new revisions created on default.

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.