Commit 0bb58159 authored by catch's avatar catch
Browse files

Issue #3551446 by amateescu: Rename the workspace association service to workspace tracker

(cherry picked from commit 9de676ee)
parent 633128ec
Loading
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -45011,6 +45011,12 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/workspaces/src/Plugin/Validation/Constraint/EntityWorkspaceConflictConstraintValidator.php',
];
$ignoreErrors[] = [
	'message' => '#^Variable \\$transaction in isset\\(\\) always exists and is not nullable\\.$#',
	'identifier' => 'isset.variable',
	'count' => 2,
	'path' => __DIR__ . '/modules/workspaces/src/WorkspaceTracker.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\workspaces\\\\WorkspaceAssociation\\:\\:deleteAssociations\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -45035,12 +45041,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/workspaces/src/WorkspaceAssociation.php',
];
$ignoreErrors[] = [
	'message' => '#^Variable \\$transaction in isset\\(\\) always exists and is not nullable\\.$#',
	'identifier' => 'isset.variable',
	'count' => 2,
	'path' => __DIR__ . '/modules/workspaces/src/WorkspaceAssociation.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\workspaces\\\\WorkspaceAssociationInterface\\:\\:deleteAssociations\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
+1 −1
Original line number Diff line number Diff line
@@ -25,6 +25,6 @@ services:
    arguments: ['@entity_type.manager']
  content_moderation.workspace_subscriber:
    class: Drupal\content_moderation\EventSubscriber\WorkspaceSubscriber
    arguments: ['@entity_type.manager', '@?workspaces.association']
    arguments: ['@entity_type.manager', '@?workspaces.tracker']
  Drupal\content_moderation\EventSubscriber\DefaultContentSubscriber:
    autowire: true
+5 −5
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\workspaces\Event\WorkspacePrePublishEvent;
use Drupal\workspaces\Event\WorkspacePublishEvent;
use Drupal\workspaces\WorkspaceAssociationInterface;
use Drupal\workspaces\WorkspaceTrackerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
@@ -19,12 +19,12 @@ class WorkspaceSubscriber implements EventSubscriberInterface {
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager service.
   * @param \Drupal\workspaces\WorkspaceAssociationInterface|null $workspaceAssociation
   *   The workspace association service.
   * @param \Drupal\workspaces\WorkspaceTrackerInterface|null $workspaceTracker
   *   The workspace tracker service.
   */
  public function __construct(
    protected readonly EntityTypeManagerInterface $entityTypeManager,
    protected readonly ?WorkspaceAssociationInterface $workspaceAssociation,
    protected readonly ?WorkspaceTrackerInterface $workspaceTracker,
  ) {}

  /**
@@ -38,7 +38,7 @@ public function onWorkspacePrePublish(WorkspacePublishEvent $event): void {
    // revisions in a moderation state that doesn't create default revisions.
    $workspace = $event->getWorkspace();

    $tracked_revisions = $this->workspaceAssociation->getTrackedEntities($workspace->id());
    $tracked_revisions = $this->workspaceTracker->getTrackedEntities($workspace->id());

    // Gather a list of moderation states that don't create a default revision.
    $workflow_non_default_states = [];
+17 −3
Original line number Diff line number Diff line
@@ -185,6 +185,20 @@ public function getProvider(): WorkspaceProviderInterface {
    return $provider_collector->getProvider($this->get('provider')->value);
  }

  /**
   * {@inheritdoc}
   */
  public function postSave(EntityStorageInterface $storage, $update = TRUE): void {
    parent::postSave($storage, $update);

    // When a new workspace has been saved, we need to copy all the associations
    // of its parent.
    if (!$update && $this->hasParent()) {
      \Drupal::service('workspaces.tracker')->initializeWorkspace($this);
    }
    \Drupal::service('workspaces.repository')->resetCache();
  }

  /**
   * {@inheritdoc}
   */
@@ -209,8 +223,8 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti

    /** @var \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager */
    $workspace_manager = \Drupal::service('workspaces.manager');
    /** @var \Drupal\workspaces\WorkspaceAssociationInterface $workspace_association */
    $workspace_association = \Drupal::service('workspaces.association');
    /** @var \Drupal\workspaces\WorkspaceTrackerInterface $workspace_tracker */
    $workspace_tracker = \Drupal::service('workspaces.tracker');

    // Gather the list of deleted workspace IDs, since the passed-in array is
    // not required to be keyed by them.
@@ -227,7 +241,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti
    // from \Drupal\workspaces\Hook\WorkspacesHooks::cron().
    $workspace_ids_to_purge = [];
    foreach ($workspaces_ids as $workspace_id) {
      if ($workspace_association->getTrackedEntities($workspace_id)) {
      if ($workspace_tracker->getTrackedEntities($workspace_id)) {
        $workspace_ids_to_purge[$workspace_id] = $workspace_id;
      }
    }
+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\workspaces\WorkspaceAssociation;
use Drupal\workspaces\WorkspaceTracker;
use Drupal\workspaces\WorkspaceInformationInterface;
use Drupal\workspaces\WorkspaceManagerInterface;

@@ -85,7 +85,7 @@ public function prepare() {
      // can properly include live content along with a possible workspace
      // revision.
      $id_field = $this->entityType->getKey('id');
      $target_id_field = WorkspaceAssociation::getIdField($this->entityTypeId);
      $target_id_field = WorkspaceTracker::getIdField($this->entityTypeId);
      $this->sqlQuery->leftJoin('workspace_association', 'workspace_association', "[%alias].[target_entity_type_id] = '{$this->entityTypeId}' AND [%alias].[$target_id_field] = [base_table].[$id_field] AND [%alias].[workspace] = '{$active_workspace->id()}'");
    }

Loading