1 | <?php |
||
23 | class Base implements QueryInterface |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * A limit to the number of rounds that the report builder will run |
||
28 | * @var integer |
||
29 | */ |
||
30 | protected $numberDataSets = 1; |
||
31 | |||
32 | /** |
||
33 | * pointer tracking |
||
34 | * @var integer |
||
35 | */ |
||
36 | protected $currentDataSet = 0; |
||
37 | |||
38 | /** |
||
39 | * For any query modifiers that will be used when the data query is run. |
||
40 | * This gets reset every record set |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $modifiers = []; |
||
45 | |||
46 | /** |
||
47 | * A Doctrine query object that is used for pulling data in to the builder |
||
48 | * @var object |
||
49 | */ |
||
50 | protected $queryBase; |
||
51 | |||
52 | /** |
||
53 | * The Doctrine repository class used in the query |
||
54 | * @var object |
||
55 | */ |
||
56 | protected $repository; |
||
57 | |||
58 | /** |
||
59 | * Stringify the current data set |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public function __toString() |
||
67 | |||
68 | /** |
||
69 | * Set the tracking parameters back to their base value |
||
70 | * @return $this |
||
71 | */ |
||
72 | public function reset() |
||
79 | |||
80 | /** |
||
81 | * Inform the service how many rounds the report will go through |
||
82 | * |
||
83 | * @param integer $count |
||
84 | * @return $this |
||
85 | * @throws \InvalidArgumentException if count not an integer, zero or less |
||
86 | */ |
||
87 | public function setNumberDataSets($count) |
||
99 | |||
100 | /** |
||
101 | * Attempt to move the query counter forward and halt operations if at end |
||
102 | * |
||
103 | * @return boolean True if can continue |
||
104 | */ |
||
105 | public function tick() |
||
115 | |||
116 | /** |
||
117 | * Set the Doctrine query repository to be used |
||
118 | * |
||
119 | * @param ObjectRepository $repository |
||
120 | * @return $this |
||
121 | */ |
||
122 | public function setRepository(ObjectRepository $repository) |
||
128 | |||
129 | /** |
||
130 | * Set the Query Builder object which will form the basis of all information |
||
131 | * gathering |
||
132 | * |
||
133 | * @param object $query |
||
134 | * @return $this |
||
135 | */ |
||
136 | public function setQueryBase($query) |
||
143 | |||
144 | /** |
||
145 | * Influence the current query that will be run by adding modifier conditions |
||
146 | * |
||
147 | * @param string $field The database field |
||
148 | * @param array $options Options associated with the modifier |
||
149 | * @return $this |
||
150 | * @throws \InvalidArgumentException If minimum options are not set |
||
151 | */ |
||
152 | public function addModifier($field, $options = []) |
||
163 | |||
164 | /** |
||
165 | * Using the query base and available modifiers, create the base part of the |
||
166 | * database query to be run in the current data set |
||
167 | * |
||
168 | * @return object QueryBuilder |
||
169 | * @throws \Exception If an unrecognized query modifier is being used |
||
170 | */ |
||
171 | public function prepareQuery() |
||
200 | |||
201 | /** |
||
202 | * Attempt to build the actual database operation and return the result |
||
203 | * @return type |
||
204 | * @throws \Exception |
||
205 | */ |
||
206 | public function run() |
||
225 | |||
226 | /** |
||
227 | * Return the Doctrine repository object |
||
228 | * @return object |
||
229 | */ |
||
230 | public function getRepository() |
||
234 | |||
235 | /** |
||
236 | * Return the current set counter |
||
237 | * |
||
238 | * @return integer |
||
239 | */ |
||
240 | public function getNumberDataSetCurrent() |
||
244 | |||
245 | /** |
||
246 | * Return the total number of data sets to be run |
||
247 | * |
||
248 | * @return integer |
||
249 | */ |
||
250 | public function getNumberDataSetCount() |
||
254 | |||
255 | /** |
||
256 | * Return the current modifiers in their array definition format |
||
257 | * |
||
258 | * @return array |
||
259 | */ |
||
260 | public function getModifiers() |
||
264 | /** |
||
265 | * Display the set heading |
||
266 | * |
||
267 | * @return string |
||
268 | */ |
||
269 | public function getTitle() |
||
273 | } |
||
274 |