public function EntityLegalDocument::getPublishedVersion in Entity Legal 3.0.x
Same name and namespace in other branches
- 8.2 src/Entity/EntityLegalDocument.php \Drupal\entity_legal\Entity\EntityLegalDocument::getPublishedVersion()
- 4.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\EntityCode
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);
$published_version = $storage
->load($id);
$current_langcode = \Drupal::languageManager()
->getCurrentLanguage()
->getId();
if ($published_version
->hasTranslation($current_langcode)) {
$published_version = $published_version
->getTranslation($current_langcode);
}
return $published_version;
}