You are here

protected function ModerationInformation::isFirstTimeModeration in Drupal 9

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

Determines if this entity is being moderated for the first time.

If the previous version of the entity has no moderation state, we assume that means it predates the presence of moderation states.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity being moderated.

Return value

bool TRUE if this is the entity's first time being moderated, FALSE otherwise.

1 call to ModerationInformation::isFirstTimeModeration()
ModerationInformation::getOriginalState in core/modules/content_moderation/src/ModerationInformation.php
Gets the original or initial state of the given entity.

File

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

Class

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

Namespace

Drupal\content_moderation

Code

protected function isFirstTimeModeration(ContentEntityInterface $entity) {
  $storage = $this->entityTypeManager
    ->getStorage($entity
    ->getEntityTypeId());
  $original_entity = $storage
    ->loadRevision($storage
    ->getLatestRevisionId($entity
    ->id()));
  if ($original_entity) {
    $original_id = $original_entity->moderation_state;
  }
  return !($entity->moderation_state && $original_entity && $original_id);
}