You are here

public function EntityLegalDocument::getPublishedVersion in Entity Legal 8.2

Same name and namespace in other branches
  1. 4.0.x src/Entity/EntityLegalDocument.php \Drupal\entity_legal\Entity\EntityLegalDocument::getPublishedVersion()
  2. 3.0.x src/Entity/EntityLegalDocument.php \Drupal\entity_legal\Entity\EntityLegalDocument::getPublishedVersion()

Get the current published version of this document.

Return value

bool|EntityLegalDocumentVersionInterface The current legal document version or FALSE if none found.

Overrides EntityLegalDocumentInterface::getPublishedVersion

4 calls to EntityLegalDocument::getPublishedVersion()
EntityLegalDocument::getAcceptanceLabel in src/Entity/EntityLegalDocument.php
Get the label to be shown on the acceptance checkbox.
EntityLegalDocument::getAcceptances in src/Entity/EntityLegalDocument.php
Get the acceptances for this entity legal document revision.
EntityLegalDocument::setPublishedVersion in src/Entity/EntityLegalDocument.php
Set the published document version.
EntityLegalDocument::userMustAgree in src/Entity/EntityLegalDocument.php
Checks to see if a given user can agree to this document.

File

src/Entity/EntityLegalDocument.php, line 145

Class

EntityLegalDocument
Defines the entity legal document entity.

Namespace

Drupal\entity_legal\Entity

Code

public function getPublishedVersion() {
  $storage = $this
    ->entityTypeManager()
    ->getStorage(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME);
  $ids = $storage
    ->getQuery()
    ->condition('document_name', $this
    ->id())
    ->condition('published', TRUE)
    ->execute();
  if (!$ids) {
    return FALSE;
  }
  $id = reset($ids);
  return $storage
    ->load($id);
}