You are here

class QueryFactory in CiviCRM Entity 8.3

Factory class creating entity query objects in CiviCRM.

Hierarchy

Expanded class hierarchy of QueryFactory

See also

\Drupal\civicrm_entity\Entity\Query\CiviCRM\Query

1 string reference to 'QueryFactory'
civicrm_entity.services.yml in ./civicrm_entity.services.yml
civicrm_entity.services.yml
1 service uses QueryFactory
entity.query.civicrm_entity in ./civicrm_entity.services.yml
\Drupal\civicrm_entity\Entity\Query\CiviCRM\QueryFactory

File

src/Entity/Query/CiviCRM/QueryFactory.php, line 16

Namespace

Drupal\civicrm_entity\Entity\Query\CiviCRM
View source
class QueryFactory implements QueryFactoryInterface {

  /**
   * The namespace of this class, the parent class etc.
   *
   * @var array
   */
  protected $namespaces;

  /**
   * The CiviCRM API service.
   *
   * @var \Drupal\civicrm_entity\CiviCrmApiInterface
   */
  protected $civicrmApi;

  /**
   * Constructs a QueryFactory object.
   *
   * @param \Drupal\civicrm_entity\CiviCrmApiInterface $civicrm_api
   *   The CiviCRM API bridge.
   */
  public function __construct(CiviCrmApiInterface $civicrm_api) {
    $this->namespaces = QueryBase::getNamespaces($this);
    $this->civicrmApi = $civicrm_api;
  }

  /**
   * {@inheritdoc}
   */
  public function get(EntityTypeInterface $entity_type, $conjunction) {

    // @todo copy paste, evaluate if they do.
    if ($conjunction == 'OR') {
      throw new QueryException("CiviCRM entity queries do not support OR conditions.");
    }
    $class = QueryBase::getClass($this->namespaces, 'Query');
    return new $class($entity_type, $conjunction, $this->namespaces, $this->civicrmApi);
  }

  /**
   * {@inheritdoc}
   */
  public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {

    // @todo copy paste, evaluate if they do.
    throw new QueryException("CiviCRM entity queries do not support aggregate queries.");
  }

}

Members

Namesort descending Modifiers Type Description Overrides
QueryFactory::$civicrmApi protected property The CiviCRM API service.
QueryFactory::$namespaces protected property The namespace of this class, the parent class etc.
QueryFactory::get public function Instantiates an entity query for a given entity type. Overrides QueryFactoryInterface::get
QueryFactory::getAggregate public function Instantiates an aggregation query object for a given entity type. Overrides QueryFactoryInterface::getAggregate
QueryFactory::__construct public function Constructs a QueryFactory object.