public function ModerationInformation::hasPendingRevision in Drupal 8
Same name and namespace in other branches
- 9 core/modules/content_moderation/src/ModerationInformation.php \Drupal\content_moderation\ModerationInformation::hasPendingRevision()
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 ModerationInformationInterface::hasPendingRevision
File
- core/
modules/ content_moderation/ src/ ModerationInformation.php, line 147
Class
- ModerationInformation
- General service for moderation-related questions about Entity API.
Namespace
Drupal\content_moderationCode
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 !== NULL && $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;
}