$tracked_revision_ids =
array_reduce(array_map('array_keys',
$tracked_revisions), 'array_merge',
[]);
// Gather a list of moderation states that don't create a default revision.
$workflow_non_default_states =
[];
foreach ($this->entityTypeManager->
getStorage('workflow'
)->
loadByProperties(['type' => 'content_moderation'
]) as $workflow) { /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModerationInterface $workflow_type */
$workflow_type =
$workflow->
getTypePlugin();
// Find all workflows which are moderating entity types of the same type
// to those that are tracked by the workspace.
if (array_intersect($workflow_type->
getEntityTypes(),
array_keys($tracked_revisions))) { $workflow_non_default_states[$workflow->
id()] =
array_filter(array_map(function DContentModerationState
$state) { return !
$state->
isDefaultRevisionState() ?
$state->
id() : NULL;
},
$workflow_type->
getStates()));
} } // Check if any revisions that are about to be published are in a
// non-default revision moderation state.
$query =
$this->entityTypeManager->
getStorage('content_moderation_state'
)->
getQuery() ->
allRevisions() ->
accessCheck(FALSE
);
$query->
condition('content_entity_revision_id',
$tracked_revision_ids, 'IN'
);