$entity_type =
$entity->
getEntityType();
// Only run if we are not dealing with an entity type provided by the
// Workspaces module, an internal entity type or if we are in a non-default
// workspace.
if ($this->
shouldSkipPreOperations($entity_type)) { return;
} // Disallow any change to an unsupported entity when we are not in the
// default workspace.
if (!
$this->workspaceManager->
isEntityTypeSupported($entity_type)) { throw new \
RuntimeException('This entity can only be saved in the default workspace.'
);
} /** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\Core\Entity\EntityPublishedInterface $entity */
if (!
$entity->
isNew() && !
$entity->
isSyncing()) { // Force a new revision if the entity is not replicating.
$entity->
setNewRevision(TRUE
);
// All entities in the non-default workspace are pending revisions,
// regardless of their publishing status. This means that when creating
// a published pending revision in a non-default workspace it will also be