aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Search/QueryOptimizer/QueryOptimizerStep.php
blob: 15b5b580ec16f9fd644fedb4d7ed982d3a572e9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OC\Files\Search\QueryOptimizer;

use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchOperator;

class QueryOptimizerStep {
	/**
	 * Allow optimizer steps to inspect the entire query before starting processing
	 *
	 * @param ISearchOperator $operator
	 * @return void
	 */
	public function inspectOperator(ISearchOperator $operator): void {
		if ($operator instanceof ISearchBinaryOperator) {
			foreach ($operator->getArguments() as $argument) {
				$this->inspectOperator($argument);
			}
		}
	}

	/**
	 * Allow optimizer steps to modify query operators
	 *
	 * @param ISearchOperator $operator
	 * @return void
	 */
	public function processOperator(ISearchOperator &$operator) {
		if ($operator instanceof ISearchBinaryOperator) {
			foreach ($operator->getArguments() as $argument) {
				$this->processOperator($argument);
			}
		}
	}
}