function WorkspaceAssociation::deleteAssociations
Same name in other branches
- 9 core/modules/workspaces/src/WorkspaceAssociation.php \Drupal\workspaces\WorkspaceAssociation::deleteAssociations()
- 8.9.x core/modules/workspaces/src/WorkspaceAssociation.php \Drupal\workspaces\WorkspaceAssociation::deleteAssociations()
- 10 core/modules/workspaces/src/WorkspaceAssociation.php \Drupal\workspaces\WorkspaceAssociation::deleteAssociations()
1 call to WorkspaceAssociation::deleteAssociations()
- WorkspaceAssociation::onPostPublish in core/
modules/ workspaces/ src/ WorkspaceAssociation.php - Triggers clean-up operations after a workspace is published.
File
-
core/
modules/ workspaces/ src/ WorkspaceAssociation.php, line 325
Class
- WorkspaceAssociation
- Provides a class for CRUD operations on workspace associations.
Namespace
Drupal\workspacesCode
public function deleteAssociations($workspace_id = NULL, $entity_type_id = NULL, $entity_ids = NULL, $revision_ids = NULL) {
if (!$workspace_id && !$entity_type_id) {
throw new \InvalidArgumentException('A workspace ID or an entity type ID must be provided.');
}
$query = $this->database
->delete(static::TABLE);
if ($workspace_id) {
$query->condition('workspace', $workspace_id);
}
if ($entity_type_id) {
if (!$entity_ids && !$revision_ids) {
throw new \InvalidArgumentException('A list of entity IDs or revision IDs must be provided for an entity type.');
}
$query->condition('target_entity_type_id', $entity_type_id, '=');
if ($entity_ids) {
$query->condition('target_entity_id', $entity_ids, 'IN');
}
if ($revision_ids) {
$query->condition('target_entity_revision_id', $revision_ids, 'IN');
}
}
$query->execute();
$this->associatedRevisions = $this->associatedInitialRevisions = [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.