public function ModerationInformation::hasPendingRevision in Config Entity Revisions 8.2
Determines if a pending revision exists for the specified entity.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity which may or may not have a pending revision.
Return value
bool TRUE if this entity has pending revisions available, FALSE otherwise.
Overrides ModerationInformation::hasPendingRevision
File
- src/
ModerationInformation.php, line 164
Class
- ModerationInformation
- Class ModerationInformation.
Namespace
Drupal\config_entity_revisionsCode
public function hasPendingRevision(ContentEntityInterface $entity) {
$result = FALSE;
if ($this
->isModeratedEntity($entity)) {
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage = $this->entityTypeManager
->getStorage($entity
->getEntityTypeId());
$latest_revision_id = $storage
->getLatestTranslationAffectedRevisionId($entity
->id(), $entity
->language()
->getId());
$default_revision_id = $entity
->isDefaultRevision() && !$entity
->isNewRevision() && ($revision_id = $entity
->getRevisionId()) ? $revision_id : $this
->getDefaultRevisionId($entity
->getEntityTypeId(), $entity
->id());
if ($latest_revision_id != $default_revision_id) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $latest_revision */
$latest_revision = $storage
->loadRevision($latest_revision_id);
$result = !$latest_revision
->wasDefaultRevision();
}
}
return $result;
}