|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * @copyright 2021 Anna Larch <anna.larch@gmx.net> |
| 7 | + * |
| 8 | + * @author Anna Larch <anna.larch@gmx.net> |
| 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 | +namespace OC\Calendar; |
| 27 | + |
| 28 | +use OCP\Calendar\ICalendarQuery; |
| 29 | + |
| 30 | +class CalendarQuery implements ICalendarQuery { |
| 31 | + |
| 32 | + /** @var string */ |
| 33 | + private $principalUri; |
| 34 | + |
| 35 | + /** @var array */ |
| 36 | + public $searchProperties; |
| 37 | + |
| 38 | + /** @var string|null */ |
| 39 | + private $searchPattern; |
| 40 | + |
| 41 | + /** @var array */ |
| 42 | + private $options; |
| 43 | + |
| 44 | + /** @var int|null */ |
| 45 | + private $offset; |
| 46 | + |
| 47 | + /** @var int|null */ |
| 48 | + private $limit; |
| 49 | + |
| 50 | + /** @var array */ |
| 51 | + private $calendarUris; |
| 52 | + |
| 53 | + public function __construct(string $principalUri) { |
| 54 | + $this->principalUri = $principalUri; |
| 55 | + $this->searchProperties = []; |
| 56 | + $this->options = [ |
| 57 | + 'types' => [], |
| 58 | + ]; |
| 59 | + } |
| 60 | + |
| 61 | + public function getPrincipalUri(): string { |
| 62 | + return $this->principalUri; |
| 63 | + } |
| 64 | + |
| 65 | + public function setPrincipalUri(string $principalUri): void { |
| 66 | + $this->principalUri = $principalUri; |
| 67 | + } |
| 68 | + |
| 69 | + public function setSearchPattern(string $pattern): void { |
| 70 | + $this->searchPattern = $pattern; |
| 71 | + } |
| 72 | + |
| 73 | + public function getSearchPattern(): ?string { |
| 74 | + return $this->searchPattern; |
| 75 | + } |
| 76 | + |
| 77 | + public function addSearchProperty(string $value): void { |
| 78 | + $this->searchProperties[] = $value; |
| 79 | + } |
| 80 | + |
| 81 | + public function getSearchProperties(): array { |
| 82 | + return $this->searchProperties; |
| 83 | + } |
| 84 | + |
| 85 | + public function addSearchCalendar(string $calendarUri): void { |
| 86 | + $this->calendarUris[] = $calendarUri; |
| 87 | + } |
| 88 | + |
| 89 | + public function getCalendarUris(): array { |
| 90 | + return $this->calendarUris; |
| 91 | + } |
| 92 | + |
| 93 | + public function getLimit(): ?int { |
| 94 | + return $this->limit; |
| 95 | + } |
| 96 | + |
| 97 | + public function setLimit(int $limit): void { |
| 98 | + $this->limit = $limit; |
| 99 | + } |
| 100 | + |
| 101 | + public function getOffset(): ?int { |
| 102 | + return $this->offset; |
| 103 | + } |
| 104 | + |
| 105 | + public function setOffset(int $offset): void { |
| 106 | + $this->offset = $offset; |
| 107 | + } |
| 108 | + |
| 109 | + public function addType(string $value): void { |
| 110 | + $this->options['types'][] = $value; |
| 111 | + } |
| 112 | + |
| 113 | + public function setTimerangeStart(\DateTimeImmutable $startTime): void { |
| 114 | + $this->options['timerange']['start'] = $startTime; |
| 115 | + } |
| 116 | + |
| 117 | + public function setTimerangeEnd(\DateTimeImmutable $endTime): void { |
| 118 | + $this->options['timerange']['end'] = $endTime; |
| 119 | + } |
| 120 | + |
| 121 | + public function getOptions(): array { |
| 122 | + return $this->options; |
| 123 | + } |
| 124 | +} |
0 commit comments