From b4c49241ce2ce7457142910eac59747fdb0420f2 Mon Sep 17 00:00:00 2001
From: Andrei Mateescu <andrei@amateescu.me>
Date: Fri, 1 Mar 2024 17:21:00 +0200
Subject: [PATCH] Modernize the QueryFactory class overrides.

---
 .../src/EntityQuery/PgsqlQueryFactory.php     | 47 ++-----------------
 .../src/EntityQuery/QueryFactory.php          | 35 ++------------
 2 files changed, 8 insertions(+), 74 deletions(-)

diff --git a/core/modules/workspaces/src/EntityQuery/PgsqlQueryFactory.php b/core/modules/workspaces/src/EntityQuery/PgsqlQueryFactory.php
index 5b15656538ea..f0597ee92415 100644
--- a/core/modules/workspaces/src/EntityQuery/PgsqlQueryFactory.php
+++ b/core/modules/workspaces/src/EntityQuery/PgsqlQueryFactory.php
@@ -2,52 +2,11 @@
 
 namespace Drupal\workspaces\EntityQuery;
 
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Core\Entity\Query\QueryBase;
-use Drupal\Core\Entity\Query\Sql\pgsql\QueryFactory as BaseQueryFactory;
-use Drupal\workspaces\WorkspaceManagerInterface;
-
 /**
  * Workspaces PostgreSQL-specific entity query implementation.
+ *
+ * @internal
  */
-class PgsqlQueryFactory extends BaseQueryFactory {
-
-  /**
-   * The workspace manager.
-   *
-   * @var \Drupal\workspaces\WorkspaceManagerInterface
-   */
-  protected $workspaceManager;
-
-  /**
-   * Constructs a PgsqlQueryFactory object.
-   *
-   * @param \Drupal\Core\Database\Connection $connection
-   *   The database connection used by the entity query.
-   * @param \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager
-   *   The workspace manager.
-   */
-  public function __construct(Connection $connection, WorkspaceManagerInterface $workspace_manager) {
-    $this->connection = $connection;
-    $this->workspaceManager = $workspace_manager;
-    $this->namespaces = QueryBase::getNamespaces($this);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function get(EntityTypeInterface $entity_type, $conjunction) {
-    $class = QueryBase::getClass($this->namespaces, 'Query');
-    return new $class($entity_type, $conjunction, $this->connection, $this->namespaces, $this->workspaceManager);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
-    $class = QueryBase::getClass($this->namespaces, 'QueryAggregate');
-    return new $class($entity_type, $conjunction, $this->connection, $this->namespaces, $this->workspaceManager);
-  }
+class PgsqlQueryFactory extends QueryFactory {
 
 }
diff --git a/core/modules/workspaces/src/EntityQuery/QueryFactory.php b/core/modules/workspaces/src/EntityQuery/QueryFactory.php
index 21ea87002c40..0594fbc79acc 100644
--- a/core/modules/workspaces/src/EntityQuery/QueryFactory.php
+++ b/core/modules/workspaces/src/EntityQuery/QueryFactory.php
@@ -16,37 +16,12 @@
  */
 class QueryFactory extends BaseQueryFactory {
 
-  /**
-   * The workspace manager.
-   *
-   * @var \Drupal\workspaces\WorkspaceManagerInterface
-   */
-  protected $workspaceManager;
-
-  /**
-   * The workspace information service.
-   *
-   * @var \Drupal\workspaces\WorkspaceInformationInterface
-   */
-  protected $workspaceInfo;
-
-  /**
-   * Constructs a QueryFactory object.
-   *
-   * Initializes the list of namespaces used to locate query
-   * classes for different entity types.
-   *
-   * @param \Drupal\Core\Database\Connection $connection
-   *   The database connection used by the entity query.
-   * @param \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager
-   *   The workspace manager.
-   * @param \Drupal\workspaces\WorkspaceInformationInterface $workspace_information
-   *   The workspace information service.
-   */
-  public function __construct(Connection $connection, WorkspaceManagerInterface $workspace_manager, protected WorkspaceInformationInterface $workspace_information) {
+  public function __construct(
+    Connection $connection,
+    protected readonly WorkspaceManagerInterface $workspaceManager,
+    protected readonly WorkspaceInformationInterface $workspaceInfo
+  ) {
     $this->connection = $connection;
-    $this->workspaceManager = $workspace_manager;
-    $this->workspaceInfo = $workspace_information;
     $this->namespaces = QueryBase::getNamespaces($this);
   }
 
-- 
GitLab