CachedSubscriptionObject.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\CalDAV;
  8. use Sabre\DAV\Exception\MethodNotAllowed;
  9. /**
  10. * Class CachedSubscriptionObject
  11. *
  12. * @package OCA\DAV\CalDAV
  13. * @property CalDavBackend $caldavBackend
  14. */
  15. class CachedSubscriptionObject extends \Sabre\CalDAV\CalendarObject {
  16. /**
  17. * @inheritdoc
  18. */
  19. public function get() {
  20. // Pre-populating the 'calendardata' is optional, if we don't have it
  21. // already we fetch it from the backend.
  22. if (!isset($this->objectData['calendardata'])) {
  23. $this->objectData = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $this->objectData['uri'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
  24. }
  25. return $this->objectData['calendardata'];
  26. }
  27. /**
  28. * @param resource|string $calendarData
  29. * @return string
  30. * @throws MethodNotAllowed
  31. */
  32. public function put($calendarData) {
  33. throw new MethodNotAllowed('Creating objects in a cached subscription is not allowed');
  34. }
  35. /**
  36. * @throws MethodNotAllowed
  37. */
  38. public function delete() {
  39. throw new MethodNotAllowed('Deleting objects in a cached subscription is not allowed');
  40. }
  41. }