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