PgsqlQueryFactory.php 1.63 KB
Newer Older
1 2
<?php

3
namespace Drupal\workspaces\EntityQuery;
4 5 6 7 8

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;
9
use Drupal\workspaces\WorkspaceManagerInterface;
10 11

/**
12
 * Workspaces PostgreSQL-specific entity query implementation.
13 14 15 16 17 18
 */
class PgsqlQueryFactory extends BaseQueryFactory {

  /**
   * The workspace manager.
   *
19
   * @var \Drupal\workspaces\WorkspaceManagerInterface
20 21 22 23 24 25 26 27
   */
  protected $workspaceManager;

  /**
   * Constructs a PgsqlQueryFactory object.
   *
   * @param \Drupal\Core\Database\Connection $connection
   *   The database connection used by the entity query.
28
   * @param \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
   *   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);
  }

}