// Existing entities will have a corresponding content_moderation_state
// entity associated with them.
if (!
$entity->
isNew() &&
$content_moderation_state =
$this->
loadContentModerationStateRevision($entity)) { return $content_moderation_state->moderation_state->value;
} // It is possible that the bundle does not exist at this point. For example,
// the node type form creates a fake Node entity to get default values.
// @see \Drupal\node\NodeTypeForm::form()
$workflow =
$moderation_info->
getWorkFlowForEntity($entity);
return $workflow ?
$workflow->
getTypePlugin()->
getInitialState($entity)->
id() : NULL;
} /**
* Load the content moderation state revision associated with an entity.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The entity the content moderation state entity will be loaded from.
*
* @return \Drupal\content_moderation\Entity\ContentModerationStateInterface|null
* The content_moderation_state revision or FALSE if none exists.
*/