|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * @copyright Copyright (c) 2023 Andrew Summers |
| 7 | + * |
| 8 | + * @author Andrew Summers |
| 9 | + * |
| 10 | + * @license GNU AGPL version 3 or any later version |
| 11 | + * |
| 12 | + * This program is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU Affero General Public License as |
| 14 | + * published by the Free Software Foundation, either version 3 of the |
| 15 | + * License, or (at your option) any later version. |
| 16 | + * |
| 17 | + * This program is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU Affero General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU Affero General Public License |
| 23 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + * |
| 25 | + */ |
| 26 | + |
| 27 | +namespace OC\DB\QueryBuilder\Events; |
| 28 | + |
| 29 | +use OCP\EventDispatcher\Event; |
| 30 | +use OCP\DB\QueryBuilder\IQueryBuilder; |
| 31 | + |
| 32 | +/** |
| 33 | + * This event is used by apps to intercept, inspect, and potentially modify |
| 34 | + * database queries prior to execution. This can be used for deep integrations, |
| 35 | + * restricting user access to certain data, redacting information, etc. |
| 36 | + * |
| 37 | + * The result field can optionally be set by the event listener by executing the |
| 38 | + * query in the event handler logic. This allows apps to inspect the results, |
| 39 | + * use try/catch blocks around the query execution, and/or modify/re-execute the |
| 40 | + * query if necessary. If the result field is not set, the QueryBuilder class |
| 41 | + * will execute the query as expected by default. |
| 42 | + * |
| 43 | + * @see https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/projects.html |
| 44 | + * @since 26.0.0 |
| 45 | + */ |
| 46 | +class BeforeQueryExecuted extends Event { |
| 47 | + private IQueryBuilder $queryBuilder; |
| 48 | + private $result = null; |
| 49 | + |
| 50 | + public function __construct(IQueryBuilder $queryBuilder) { |
| 51 | + $this->queryBuilder = $queryBuilder; |
| 52 | + } |
| 53 | + |
| 54 | + public function getQueryBuilder() { |
| 55 | + return $this->queryBuilder; |
| 56 | + } |
| 57 | + |
| 58 | + public function setQueryBuilder() { |
| 59 | + return $this->queryBuilder; |
| 60 | + } |
| 61 | + |
| 62 | + public function getResult() { |
| 63 | + return $this->result; |
| 64 | + } |
| 65 | + |
| 66 | + public function setResult() { |
| 67 | + return $this->result; |
| 68 | + } |
| 69 | +} |
0 commit comments