ObjectQueryUnionQueryProvider.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\model;
12 
16 
17 /**
18  * ObjectQueryUnionQueryProvider provides queries as ObjectQuery instances.
19  *
20  * @author ingo herwig <ingo@wemove.com>
21  */
23  protected $queries = [];
24 
25  /**
26  * Constructor
27  * @param $queries Array of ObjectQuery instances
28  */
29  public function __construct(array $queries) {
30  $persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
31 
32  // calculate ids and assign query definitions
33  foreach ($queries as $query) {
34  $type = $persistenceFacade->getFullyQualifiedType($query->getQueryType());
35  $id = __CLASS__.','.$type.','.$query->getId();
36  $this->queries[$id] = $query;
37  }
38  }
39 
40  /**
41  * @see UnionQueryProvider::getIds()
42  */
43  public function getIds() {
44  return array_keys($this->queries);
45  }
46 
47  /**
48  * @see UnionQueryProvider::execute()
49  */
50  public function execute($queryId, $buildDepth, $orderby, $pagingInfo) {
51  $query = isset($this->queries[$queryId]) ? $this->queries[$queryId] : null;
52  if (!$query) {
53  throw new IllegalArgumentException('Query id '.$queryId.' is unknown');
54  }
55  return $query->execute($buildDepth, $orderby, $pagingInfo);
56  }
57 
58  /**
59  * Get the last query strings
60  * @return Array of string
61  */
62  public function getLastQueryStrings() {
63  $result = [];
64  foreach ($this->queries as $query) {
65  $result[] = $query->getLastQueryString();
66  }
67  return $result;
68  }
69 }
70 ?>
IllegalArgumentException signals an exception in method arguments.
UnionQueryProvider is used to provide queries to a union query.
execute($queryId, $buildDepth, $orderby, $pagingInfo)
static getInstance($name, $dynamicConfiguration=[])
ObjectQueryUnionQueryProvider provides queries as ObjectQuery instances.
Node related interfaces and classes.
Definition: namespaces.php:26
ObjectFactory implements the service locator pattern by wrapping a Factory instance and providing sta...