protected function ModerationInformation::isFirstTimeModeration in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_moderation/src/ModerationInformation.php \Drupal\content_moderation\ModerationInformation::isFirstTimeModeration()
- 9 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.
File
- core/
modules/ content_moderation/ src/ ModerationInformation.php, line 242
Class
- ModerationInformation
- General service for moderation-related questions about Entity API.
Namespace
Drupal\content_moderationCode
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);
}