getAssociatedInitialRevisions example

$count = 1;
    foreach ($all_associated_revisions as $entity_type_id => $associated_revisions) {
      $associated_entity_storage = $this->entityTypeManager->getStorage($entity_type_id);

      // Sort the associated revisions in reverse ID order, so we can delete the       // most recent revisions first.       krsort($associated_revisions);

      // Get a list of default revisions tracked by the given workspace, because       // they need to be handled differently than pending revisions.       $initial_revision_ids = $this->workspaceAssociation->getAssociatedInitialRevisions($workspace_id$entity_type_id);

      foreach (array_keys($associated_revisions) as $revision_id) {
        if ($count > $batch_size) {
          continue 2;
        }

        // If the workspace is tracking the entity's default revision (i.e. the         // entity was created inside that workspace), we need to delete the         // whole entity after all of its pending revisions are gone.         if (isset($initial_revision_ids[$revision_id])) {
          $associated_entity_storage->delete([$associated_entity_storage->load($initial_revision_ids[$revision_id])]);
        }
$tracked_entities = $workspace_association->getTrackedEntities($workspace_id$entity_type_id);
      $tracked_revision_ids = $tracked_entities[$entity_type_id] ?? [];
      $this->assertEquals($expected_tracked_revision_idsarray_keys($tracked_revision_ids));
    }

    foreach ($expected_all_revisions as $workspace_id => $expected_all_revision_ids) {
      $all_associated_revisions = $workspace_association->getAssociatedRevisions($workspace_id$entity_type_id);
      $this->assertEquals($expected_all_revision_idsarray_keys($all_associated_revisions));
    }

    foreach ($expected_initial_revisions as $workspace_id => $expected_initial_revision_ids) {
      $initial_revisions = $workspace_association->getAssociatedInitialRevisions($workspace_id$entity_type_id);
      $this->assertEquals($expected_initial_revision_idsarray_keys($initial_revisions));
    }
  }

}
    $workspace_1 = Workspace::create([
      'id' => 'gibbon',
      'label' => 'Gibbon',
    ]);
    $workspace_1->save();
    $this->workspaceManager->setActiveWorkspace($workspace_1);

    $workspace_1_node_1 = $this->createNode(['status' => FALSE]);
    $workspace_1_node_2 = $this->createNode(['status' => FALSE]);

    // Check that the workspace tracks the initial revisions for both nodes.     $initial_revisions = $workspace_association->getAssociatedInitialRevisions($workspace_1->id(), 'node');
    $this->assertCount(2, $initial_revisions);

    for ($i = 0; $i < 4; $i++) {
      $workspace_1_node_1->setNewRevision(TRUE);
      $workspace_1_node_1->save();

      $workspace_1_node_2->setNewRevision(TRUE);
      $workspace_1_node_2->save();
    }

    // The workspace should now track 2 nodes.
Home | Imprint | This part of the site doesn't use cookies.