You are here

protected function DiffEntityComparison::getModerationState in Diff 8

Gets the revision's content moderation state, if available.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity revision.

Return value

string|bool Returns the label of the moderation state, if available, otherwise FALSE.

1 call to DiffEntityComparison::getModerationState()
DiffEntityComparison::getRevisionDescription in src/DiffEntityComparison.php
Gets the revision description of the revision.

File

src/DiffEntityComparison.php, line 341

Class

DiffEntityComparison
Entity comparison service that prepares a diff of a pair of entities.

Namespace

Drupal\diff

Code

protected function getModerationState(ContentEntityInterface $entity) {
  if ($this->moderationInformation && $this->moderationInformation
    ->isModeratedEntity($entity)) {
    if ($state = $entity->moderation_state->value) {
      $workflow = $this->moderationInformation
        ->getWorkflowForEntity($entity);
      return $workflow
        ->getTypePlugin()
        ->getState($state)
        ->label();
    }
  }
  return FALSE;
}