ShareeList.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Connector\Sabre;
  8. use OCP\Share\IShare;
  9. use Sabre\Xml\Writer;
  10. use Sabre\Xml\XmlSerializable;
  11. /**
  12. * This property contains multiple "sharee" elements, each containing a share sharee
  13. */
  14. class ShareeList implements XmlSerializable {
  15. public const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
  16. public function __construct(
  17. /** @var IShare[] */
  18. private array $shares,
  19. ) {
  20. }
  21. /**
  22. * The xmlSerialize method is called during xml writing.
  23. *
  24. * @param Writer $writer
  25. * @return void
  26. */
  27. public function xmlSerialize(Writer $writer) {
  28. foreach ($this->shares as $share) {
  29. $writer->startElement('{' . self::NS_NEXTCLOUD . '}sharee');
  30. $writer->writeElement('{' . self::NS_NEXTCLOUD . '}id', $share->getSharedWith());
  31. $writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName());
  32. $writer->writeElement('{' . self::NS_NEXTCLOUD . '}type', $share->getShareType());
  33. $writer->endElement();
  34. }
  35. }
  36. }