You are here

public function ModerationInformation::isLiveRevision in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/src/ModerationInformation.php \Drupal\content_moderation\ModerationInformation::isLiveRevision()

Determines if an entity is "live".

A "live" entity revision is one whose latest revision is also the default, and whose moderation state, if any, is a published state.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to check.

Return value

bool TRUE if the specified entity is a live revision, FALSE otherwise.

Overrides ModerationInformationInterface::isLiveRevision

File

core/modules/content_moderation/src/ModerationInformation.php, line 167

Class

ModerationInformation
General service for moderation-related questions about Entity API.

Namespace

Drupal\content_moderation

Code

public function isLiveRevision(ContentEntityInterface $entity) {
  $workflow = $this
    ->getWorkflowForEntity($entity);
  return $entity
    ->isLatestRevision() && $entity
    ->isDefaultRevision() && $entity->moderation_state->value && $workflow
    ->getTypePlugin()
    ->getState($entity->moderation_state->value)
    ->isPublishedState();
}