{} /**
* Prevents a workspace from being published based on certain conditions.
*
* @param \Drupal\workspaces\Event\WorkspacePublishEvent $event
* The workspace publish event.
*/
public function onWorkspacePrePublish(WorkspacePublishEvent
$event): void
{ // Prevent a workspace from being published if there are any pending
// revisions in a moderation state that doesn't create default revisions.
$workspace =
$event->
getWorkspace();
$tracked_revisions =
$this->workspaceAssociation->
getTrackedEntities($workspace->
id());
// Extract all the second-level keys (revision IDs) of the two-dimensional
// array.
$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();