1
0

CalendarQuery.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Calendar;
  8. use OCP\Calendar\ICalendarQuery;
  9. class CalendarQuery implements ICalendarQuery {
  10. public array $searchProperties = [];
  11. private ?string $searchPattern = null;
  12. private array $options = [
  13. 'types' => [],
  14. ];
  15. private ?int $offset = null;
  16. private ?int $limit = null;
  17. /** @var string[] */
  18. private array $calendarUris = [];
  19. public function __construct(
  20. private string $principalUri,
  21. ) {
  22. }
  23. public function getPrincipalUri(): string {
  24. return $this->principalUri;
  25. }
  26. public function setPrincipalUri(string $principalUri): void {
  27. $this->principalUri = $principalUri;
  28. }
  29. public function setSearchPattern(string $pattern): void {
  30. $this->searchPattern = $pattern;
  31. }
  32. public function getSearchPattern(): ?string {
  33. return $this->searchPattern;
  34. }
  35. public function addSearchProperty(string $value): void {
  36. $this->searchProperties[] = $value;
  37. }
  38. public function getSearchProperties(): array {
  39. return $this->searchProperties;
  40. }
  41. public function addSearchCalendar(string $calendarUri): void {
  42. $this->calendarUris[] = $calendarUri;
  43. }
  44. /**
  45. * @return string[]
  46. */
  47. public function getCalendarUris(): array {
  48. return $this->calendarUris;
  49. }
  50. public function getLimit(): ?int {
  51. return $this->limit;
  52. }
  53. public function setLimit(int $limit): void {
  54. $this->limit = $limit;
  55. }
  56. public function getOffset(): ?int {
  57. return $this->offset;
  58. }
  59. public function setOffset(int $offset): void {
  60. $this->offset = $offset;
  61. }
  62. public function addType(string $value): void {
  63. $this->options['types'][] = $value;
  64. }
  65. public function setTimerangeStart(\DateTimeImmutable $startTime): void {
  66. $this->options['timerange']['start'] = $startTime;
  67. }
  68. public function setTimerangeEnd(\DateTimeImmutable $endTime): void {
  69. $this->options['timerange']['end'] = $endTime;
  70. }
  71. public function getOptions(): array {
  72. return $this->options;
  73. }
  74. }