/**
* Acts on an entity and set published status based on the moderation state.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity being saved.
*
* @see hook_entity_presave()
*/
public function entityPresave(EntityInterface
$entity) { if (!
$this->moderationInfo->
isModeratedEntity($entity)) { return;
} 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.