You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ShareeList.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. * @author Tobias Kaminsky <tobias@kaminsky.me>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\DAV\Connector\Sabre;
  27. use OCP\Share\IShare;
  28. use Sabre\Xml\Writer;
  29. use Sabre\Xml\XmlSerializable;
  30. /**
  31. * This property contains multiple "sharee" elements, each containing a share sharee
  32. */
  33. class ShareeList implements XmlSerializable {
  34. public const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
  35. /** @var IShare[] */
  36. private $shares;
  37. public function __construct(array $shares) {
  38. $this->shares = $shares;
  39. }
  40. /**
  41. * The xmlSerialize metod is called during xml writing.
  42. *
  43. * @param Writer $writer
  44. * @return void
  45. */
  46. public function xmlSerialize(Writer $writer) {
  47. foreach ($this->shares as $share) {
  48. $writer->startElement('{' . self::NS_NEXTCLOUD . '}sharee');
  49. $writer->writeElement('{' . self::NS_NEXTCLOUD . '}id', $share->getSharedWith());
  50. $writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName());
  51. $writer->writeElement('{' . self::NS_NEXTCLOUD . '}type', $share->getShareType());
  52. $writer->endElement();
  53. }
  54. }
  55. }