CalendarQuery.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. /** @var string */
  28. private $principalUri;
  29. /** @var array */
  30. public $searchProperties;
  31. /** @var string|null */
  32. private $searchPattern;
  33. /** @var array */
  34. private $options;
  35. /** @var int|null */
  36. private $offset;
  37. /** @var int|null */
  38. private $limit;
  39. /** @var string[] */
  40. private $calendarUris = [];
  41. public function __construct(string $principalUri) {
  42. $this->principalUri = $principalUri;
  43. $this->searchProperties = [];
  44. $this->options = [
  45. 'types' => [],
  46. ];
  47. }
  48. public function getPrincipalUri(): string {
  49. return $this->principalUri;
  50. }
  51. public function setPrincipalUri(string $principalUri): void {
  52. $this->principalUri = $principalUri;
  53. }
  54. public function setSearchPattern(string $pattern): void {
  55. $this->searchPattern = $pattern;
  56. }
  57. public function getSearchPattern(): ?string {
  58. return $this->searchPattern;
  59. }
  60. public function addSearchProperty(string $value): void {
  61. $this->searchProperties[] = $value;
  62. }
  63. public function getSearchProperties(): array {
  64. return $this->searchProperties;
  65. }
  66. public function addSearchCalendar(string $calendarUri): void {
  67. $this->calendarUris[] = $calendarUri;
  68. }
  69. /**
  70. * @return string[]
  71. */
  72. public function getCalendarUris(): array {
  73. return $this->calendarUris;
  74. }
  75. public function getLimit(): ?int {
  76. return $this->limit;
  77. }
  78. public function setLimit(int $limit): void {
  79. $this->limit = $limit;
  80. }
  81. public function getOffset(): ?int {
  82. return $this->offset;
  83. }
  84. public function setOffset(int $offset): void {
  85. $this->offset = $offset;
  86. }
  87. public function addType(string $value): void {
  88. $this->options['types'][] = $value;
  89. }
  90. public function setTimerangeStart(\DateTimeImmutable $startTime): void {
  91. $this->options['timerange']['start'] = $startTime;
  92. }
  93. public function setTimerangeEnd(\DateTimeImmutable $endTime): void {
  94. $this->options['timerange']['end'] = $endTime;
  95. }
  96. public function getOptions(): array {
  97. return $this->options;
  98. }
  99. }