diff --git a/core/modules/workspace/src/Entity/Workspace.php b/core/modules/workspace/src/Entity/Workspace.php index 0cecf85..86fcec3 100644 --- a/core/modules/workspace/src/Entity/Workspace.php +++ b/core/modules/workspace/src/Entity/Workspace.php @@ -107,7 +107,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(new TranslatableMarkup('Created')) - ->setDescription(new TranslatableMarkup('The UNIX timestamp of when the workspace has been created.')); + ->setDescription(new TranslatableMarkup('The time that the workspaces was created.')); $fields['target'] = BaseFieldDefinition::create('string') ->setLabel(new TranslatableMarkup('Target workspace')) diff --git a/core/modules/workspace/src/EntityOperations.php b/core/modules/workspace/src/EntityOperations.php index 5b42f1f..b33c97c 100644 --- a/core/modules/workspace/src/EntityOperations.php +++ b/core/modules/workspace/src/EntityOperations.php @@ -120,8 +120,8 @@ public function entityPresave(EntityInterface $entity) { return; } - // Force a new revision if the entity is not replicating. if (!$entity->isNew() && !isset($entity->_isReplicating)) { + // Force a new revision if the entity is not replicating. $entity->setNewRevision(TRUE); // All entities in the non-default workspace are pending revisions, diff --git a/core/modules/workspace/src/EntityQuery/QueryFactory.php b/core/modules/workspace/src/EntityQuery/QueryFactory.php index 9feae9b..e0a9202 100644 --- a/core/modules/workspace/src/EntityQuery/QueryFactory.php +++ b/core/modules/workspace/src/EntityQuery/QueryFactory.php @@ -21,7 +21,7 @@ class QueryFactory extends BaseQueryFactory { protected $workspaceManager; /** - * Constructs a SqlQueryFactory object. + * Constructs a QueryFactory object. * * @param \Drupal\Core\Database\Connection $connection * The database connection used by the entity query. diff --git a/core/modules/workspace/src/EntityTypeInfo.php b/core/modules/workspace/src/EntityTypeInfo.php index ecfcded..fa2c4d0 100644 --- a/core/modules/workspace/src/EntityTypeInfo.php +++ b/core/modules/workspace/src/EntityTypeInfo.php @@ -89,23 +89,26 @@ public function entityTypeBuild(array &$entity_types) { */ public function formAlter(array &$form, FormStateInterface $form_state, $form_id) { $form_object = $form_state->getFormObject(); - if ($form_object instanceof EntityFormInterface) { - $entity = $form_object->getEntity(); + if (!$form_object instanceof EntityFormInterface) { + return; + } + + $entity = $form_object->getEntity(); + if (!$this->workspaceManager->entityTypeCanBelongToWorkspaces($entity->getEntityType())) { + return; + } - if ($this->workspaceManager->entityTypeCanBelongToWorkspaces($entity->getEntityType())) { - /** @var \Drupal\workspace\WorkspaceAssociationStorageInterface $workspace_association_storage */ - $workspace_association_storage = $this->entityTypeManager->getStorage('workspace_association'); - if ($workspace_ids = $workspace_association_storage->isEntityTracked($entity)) { - // An entity can only be edited in one workspace. - $workspace_id = reset($workspace_ids); + /** @var \Drupal\workspace\WorkspaceAssociationStorageInterface $workspace_association_storage */ + $workspace_association_storage = $this->entityTypeManager->getStorage('workspace_association'); + if ($workspace_ids = $workspace_association_storage->isEntityTracked($entity)) { + // An entity can only be edited in one workspace. + $workspace_id = reset($workspace_ids); - if ($workspace_id !== $this->workspaceManager->getActiveWorkspace()->id()) { - $workspace = $this->entityTypeManager->getStorage('workspace')->load($workspace_id); + if ($workspace_id !== $this->workspaceManager->getActiveWorkspace()->id()) { + $workspace = $this->entityTypeManager->getStorage('workspace')->load($workspace_id); - $form['#markup'] = $this->t('The content is being edited in the %label workspace.', ['%label' => $workspace->label()]); - $form['#access'] = FALSE; - } - } + $form['#markup'] = $this->t('The content is being edited in the %label workspace.', ['%label' => $workspace->label()]); + $form['#access'] = FALSE; } } } diff --git a/core/modules/workspace/src/Plugin/RepositoryHandler/LiveRepositoryHandler.php b/core/modules/workspace/src/Plugin/RepositoryHandler/LiveRepositoryHandler.php index daaee46..eae879c 100644 --- a/core/modules/workspace/src/Plugin/RepositoryHandler/LiveRepositoryHandler.php +++ b/core/modules/workspace/src/Plugin/RepositoryHandler/LiveRepositoryHandler.php @@ -57,7 +57,7 @@ class LiveRepositoryHandler extends RepositoryHandlerBase implements RepositoryH protected $workspaceAssociationStorage; /** - * Constructs a new DefaultRepositoryHandler. + * Constructs a new LiveRepositoryHandler. * * @param array $configuration * A configuration array containing information about the plugin instance. diff --git a/core/modules/workspace/src/Plugin/Validation/Constraint/EntityWorkspaceConflictConstraint.php b/core/modules/workspace/src/Plugin/Validation/Constraint/EntityWorkspaceConflictConstraint.php index a8ebb0a..886c700 100644 --- a/core/modules/workspace/src/Plugin/Validation/Constraint/EntityWorkspaceConflictConstraint.php +++ b/core/modules/workspace/src/Plugin/Validation/Constraint/EntityWorkspaceConflictConstraint.php @@ -15,6 +15,11 @@ */ class EntityWorkspaceConflictConstraint extends Constraint { + /** + * The default violation message. + * + * @var string + */ public $message = 'The content is being edited in the %label workspace. As a result, your changes cannot be saved.'; }