function WorkspaceTestTrait::getUnassociatedRevisions

Same name in other branches
  1. 8.9.x core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::getUnassociatedRevisions()
  2. 10 core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::getUnassociatedRevisions()
  3. 11.x core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::getUnassociatedRevisions()

Returns all the revisions which are not associated with any workspace.

Parameters

string $entity_type_id: An entity type ID to find revisions for.

int[]|string[]|null $entity_ids: (optional) An array of entity IDs to filter the results by. Defaults to NULL.

Return value

array An array of entity IDs, keyed by revision IDs.

1 call to WorkspaceTestTrait::getUnassociatedRevisions()
WorkspaceCRUDTest::testDeletingWorkspaces in core/modules/workspaces/tests/src/Kernel/WorkspaceCRUDTest.php
Tests the deletion of workspaces.

File

core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php, line 120

Class

WorkspaceTestTrait
A trait with common workspaces testing functionality.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function getUnassociatedRevisions($entity_type_id, $entity_ids = NULL) {
    $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
    $query = \Drupal::entityTypeManager()->getStorage($entity_type_id)
        ->getQuery()
        ->allRevisions()
        ->accessCheck(FALSE)
        ->notExists($entity_type->get('revision_metadata_keys')['workspace']);
    if ($entity_ids) {
        $query->condition($entity_type->getKey('id'), $entity_ids, 'IN');
    }
    return $query->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.