if ($entity->moderation_state->value
) { $workflow =
$this->moderationInfo->
getWorkflowForEntity($entity);
/** @var \Drupal\content_moderation\ContentModerationState $current_state */
$current_state =
$workflow->
getTypePlugin() ->
getState($entity->moderation_state->value
);
// This entity is default if it is new, the default revision, or the
// default revision is not published.
$update_default_revision =
$entity->
isNew() ||
$current_state->
isDefaultRevisionState() || !
$this->moderationInfo->
isDefaultRevisionPublished($entity);
// Fire per-entity-type logic for handling the save process.
$this->entityTypeManager
->
getHandler($entity->
getEntityTypeId(), 'moderation'
) ->
onPresave($entity,
$update_default_revision,
$current_state->
isPublishedState());
} } /**
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity that was just saved.
*
* @see hook_entity_insert()
*/