diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-07-30 22:51:08 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-07-30 22:51:08 +0200 |
commit | 2a4576344086adcf4c63150fc1288a850dd61ae9 (patch) | |
tree | 7734eea2dda8b459052bb611a57ec2cd2808e076 /apps/dav/lib/Connector/Sabre/ShareeList.php | |
parent | 06a9ade582c7230dbf1f34344ec33755dd929dcb (diff) | |
download | nextcloud-server-2a4576344086adcf4c63150fc1288a850dd61ae9.tar.gz nextcloud-server-2a4576344086adcf4c63150fc1288a850dd61ae9.zip |
Use proper ShareeList
This makes the XML parsing more sane ;)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/ShareeList.php')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/ShareeList.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/ShareeList.php b/apps/dav/lib/Connector/Sabre/ShareeList.php new file mode 100644 index 00000000000..8bfd992468d --- /dev/null +++ b/apps/dav/lib/Connector/Sabre/ShareeList.php @@ -0,0 +1,60 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\DAV\Connector\Sabre; + +use OCP\Share\IShare; +use Sabre\Xml\Element; +use Sabre\Xml\Reader; +use Sabre\Xml\Writer; +use Sabre\Xml\XmlSerializable; + +/** + * This property contains multiple "sharee" elements, each containing a share sharee + */ +class ShareeList implements XmlSerializable { + const NS_NEXTCLOUD = 'http://nextcloud.org/ns'; + + /** @var IShare[] */ + private $shares; + + public function __construct(array $shares) { + $this->shares = $shares; + } + + /** + * The xmlSerialize metod is called during xml writing. + * + * @param Writer $writer + * @return void + */ + function xmlSerialize(Writer $writer) { + foreach ($this->shares as $share) { + $writer->startElement('{' . self::NS_NEXTCLOUD . '}sharee'); + $writer->writeAttribute('type', $share->getShareType()); + $writer->write($share->getSharedWith()); + $writer->endElement(); + } + } +} |