ShareeList.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 method 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. }