1 | <?php |
||
11 | class QueryBuilder implements BuildsQueries |
||
12 | { |
||
13 | /** |
||
14 | * The term model |
||
15 | * @var Model |
||
16 | */ |
||
17 | protected $model; |
||
18 | |||
19 | /** |
||
20 | * Collection of arguments |
||
21 | * @var Collection |
||
22 | */ |
||
23 | protected $args; |
||
24 | |||
25 | /** |
||
26 | * Taxonomy Identifier |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $taxonomy; |
||
30 | |||
31 | /** |
||
32 | * TermQueryBuilder Constructor. |
||
33 | * |
||
34 | * @param array $args |
||
35 | */ |
||
36 | public function __construct(array $args = []) |
||
40 | |||
41 | /** |
||
42 | * Restrict the query to terms of the provided Taxonomy. |
||
43 | * |
||
44 | * @param string $taxonomy |
||
45 | * |
||
46 | * @return $this |
||
47 | */ |
||
48 | public function forTaxonomy($taxonomy) |
||
54 | |||
55 | /** |
||
56 | * Include terms that have no related objects in the results. |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function includeEmpty() |
||
66 | |||
67 | /** |
||
68 | * Limit the maximum number of results returned. |
||
69 | * |
||
70 | * @param int $max_results Maximum number to return. 0 or 'all' for unlimited. |
||
71 | * |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function limit($max_results) |
||
80 | |||
81 | /** |
||
82 | * Get the query results. |
||
83 | * |
||
84 | * @throws WP_ErrorException |
||
85 | * |
||
86 | * @return Collection |
||
87 | */ |
||
88 | public function results() |
||
100 | |||
101 | /** |
||
102 | * Get the results as a collection of models. |
||
103 | * |
||
104 | * @return Collection |
||
105 | */ |
||
106 | protected function collectModels() |
||
118 | |||
119 | /** |
||
120 | * Set the model for this query. |
||
121 | * |
||
122 | * @param mixed $model |
||
123 | * |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function setModel($model) |
||
132 | |||
133 | /** |
||
134 | * Get the model. |
||
135 | * |
||
136 | * @return mixed Model |
||
137 | */ |
||
138 | public function getModel() |
||
142 | |||
143 | /** |
||
144 | * Perform the term query and return the results. |
||
145 | * |
||
146 | * @throws WP_ErrorException |
||
147 | * |
||
148 | * @return array |
||
149 | */ |
||
150 | protected function fetchTerms() |
||
158 | } |
||
159 |