} // For a new entity, ensure the moderation state of the original entity is
// always the default state. Despite the entity being unsaved, it may have
// previously been set to a new target state, for example previewed entities
// are retrieved from temporary storage with field values set.
else { $original_entity->
set('moderation_state',
$default->
id());
} /** @var \Drupal\workflows\Transition[] $transitions */
$transitions =
$this->validator->
getValidTransitions($original_entity,
$this->currentUser
);
$transition_labels =
[];
$default_value =
$items->value;
foreach ($transitions as $transition) { $transition_to_state =
$transition->
to();
$transition_labels[$transition_to_state->
id()] =
$transition_to_state->
label();
if ($default->
id() ===
$transition_to_state->
id()) { $default_value =
$default->
id();
} }