1
0

CalendarQuery.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2021 Anna Larch <anna.larch@gmx.net>
  5. *
  6. * @author Anna Larch <anna.larch@gmx.net>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OC\Calendar;
  25. use OCP\Calendar\ICalendarQuery;
  26. class CalendarQuery implements ICalendarQuery {
  27. public array $searchProperties = [];
  28. private ?string $searchPattern = null;
  29. private array $options = [
  30. 'types' => [],
  31. ];
  32. private ?int $offset = null;
  33. private ?int $limit = null;
  34. /** @var string[] */
  35. private array $calendarUris = [];
  36. public function __construct(
  37. private string $principalUri,
  38. ) {
  39. }
  40. public function getPrincipalUri(): string {
  41. return $this->principalUri;
  42. }
  43. public function setPrincipalUri(string $principalUri): void {
  44. $this->principalUri = $principalUri;
  45. }
  46. public function setSearchPattern(string $pattern): void {
  47. $this->searchPattern = $pattern;
  48. }
  49. public function getSearchPattern(): ?string {
  50. return $this->searchPattern;
  51. }
  52. public function addSearchProperty(string $value): void {
  53. $this->searchProperties[] = $value;
  54. }
  55. public function getSearchProperties(): array {
  56. return $this->searchProperties;
  57. }
  58. public function addSearchCalendar(string $calendarUri): void {
  59. $this->calendarUris[] = $calendarUri;
  60. }
  61. /**
  62. * @return string[]
  63. */
  64. public function getCalendarUris(): array {
  65. return $this->calendarUris;
  66. }
  67. public function getLimit(): ?int {
  68. return $this->limit;
  69. }
  70. public function setLimit(int $limit): void {
  71. $this->limit = $limit;
  72. }
  73. public function getOffset(): ?int {
  74. return $this->offset;
  75. }
  76. public function setOffset(int $offset): void {
  77. $this->offset = $offset;
  78. }
  79. public function addType(string $value): void {
  80. $this->options['types'][] = $value;
  81. }
  82. public function setTimerangeStart(\DateTimeImmutable $startTime): void {
  83. $this->options['timerange']['start'] = $startTime;
  84. }
  85. public function setTimerangeEnd(\DateTimeImmutable $endTime): void {
  86. $this->options['timerange']['end'] = $endTime;
  87. }
  88. public function getOptions(): array {
  89. return $this->options;
  90. }
  91. }