function WorkspaceAssociation::deleteAssociations

Same name in other branches
  1. 9 core/modules/workspaces/src/WorkspaceAssociation.php \Drupal\workspaces\WorkspaceAssociation::deleteAssociations()
  2. 8.9.x core/modules/workspaces/src/WorkspaceAssociation.php \Drupal\workspaces\WorkspaceAssociation::deleteAssociations()
  3. 11.x core/modules/workspaces/src/WorkspaceAssociation.php \Drupal\workspaces\WorkspaceAssociation::deleteAssociations()
2 calls to WorkspaceAssociation::deleteAssociations()
WorkspaceAssociation::onPostPublish in core/modules/workspaces/src/WorkspaceAssociation.php
Triggers clean-up operations after a workspace is published.
WorkspaceAssociation::postPublish in core/modules/workspaces/src/WorkspaceAssociation.php

File

core/modules/workspaces/src/WorkspaceAssociation.php, line 373

Class

WorkspaceAssociation
Provides a class for CRUD operations on workspace associations.

Namespace

Drupal\workspaces

Code

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.