You are here

public function ConfigEntityRevisionsConfigTrait::getContentEntity in Config Entity Revisions 1.x

Same name and namespace in other branches
  1. 8 src/ConfigEntityRevisionsConfigTrait.php \Drupal\config_entity_revisions\ConfigEntityRevisionsConfigTrait::getContentEntity()

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

File

src/ConfigEntityRevisionsConfigTrait.php, line 81

Class

ConfigEntityRevisionsConfigTrait

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.
  if ($this
    ->getRevisionId()) {
    return $storage
      ->loadRevision($this
      ->getRevisionId());
  }

  // Otherwise, just get the default revision.
  return $storage
    ->load($contentEntityID);
}