You are here

public function ConfigEntityRevisionsConfigEntityTrait::getContentEntity in Config Entity Revisions 8.2

Default revision of revisions entity that matches the config entity.

Return value

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

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to ConfigEntityRevisionsConfigEntityTrait::getContentEntity()
ConfigEntityRevisionsConfigEntityTrait::__construct in src/ConfigEntityRevisionsConfigEntityTrait.php
Constructs an Entity object.

File

src/ConfigEntityRevisionsConfigEntityTrait.php, line 290

Class

ConfigEntityRevisionsConfigEntityTrait
Trait ConfigEntityRevisionsConfigEntityTrait.

Namespace

Drupal\config_entity_revisions

Code

public function getContentEntity() {
  $contentEntityID = $this
    ->getContentEntityId();
  if (!$contentEntityID) {
    return NULL;
  }

  /* @var $storage \Drupal\Core\Entity\ContentEntityStorageInterface */
  $storage = $this
    ->contentEntityStorage();

  // Get the matching revision ID if one is provided.
  return $this
    ->getRevisionId() ? $storage
    ->loadRevision($this
    ->getRevisionId()) : $storage
    ->load($contentEntityID);
}