You are here

protected function RevisionableContentEntityForm::getBundleEntity in Entity API 8

Same name and namespace in other branches
  1. 8.0 src/Form/RevisionableContentEntityForm.php \Drupal\entity\Form\RevisionableContentEntityForm::getBundleEntity()

Gets the bundle entity of the current entity.

Return value

\Drupal\Core\Entity\EntityInterface|null The bundle entity, or NULL if there is none.

Overrides ContentEntityForm::getBundleEntity

3 calls to RevisionableContentEntityForm::getBundleEntity()
RevisionableContentEntityForm::form in src/Form/RevisionableContentEntityForm.php
Gets the actual form array to be built.
RevisionableContentEntityForm::prepareEntity in src/Form/RevisionableContentEntityForm.php
Prepares the entity object before the form is built first.
RevisionableContentEntityForm::save in src/Form/RevisionableContentEntityForm.php
Form submission handler for the 'save' action.

File

src/Form/RevisionableContentEntityForm.php, line 50

Class

RevisionableContentEntityForm
Extends the base entity form with revision support in the UI.

Namespace

Drupal\entity\Form

Code

protected function getBundleEntity() {
  if ($this->entity
    ->getEntityType()
    ->getBundleEntityType()) {
    $bundle_key = $this->entity
      ->getEntityType()
      ->getKey('bundle');
    return $this->entity->{$bundle_key}
      ->referencedEntities()[0];
  }
  return NULL;
}