1 | <?php |
||
16 | class WebDAVAdapter extends AbstractAdapter |
||
17 | { |
||
18 | use StreamedTrait; |
||
19 | use StreamedCopyTrait; |
||
20 | use NotSupportingVisibilityTrait; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected static $resultMap = [ |
||
26 | '{DAV:}getcontentlength' => 'size', |
||
27 | '{DAV:}getcontenttype' => 'mimetype', |
||
28 | 'content-length' => 'size', |
||
29 | 'content-type' => 'mimetype', |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * @var Client |
||
34 | */ |
||
35 | protected $client; |
||
36 | |||
37 | /** |
||
38 | * Constructor. |
||
39 | * |
||
40 | * @param Client $client |
||
41 | * @param string $prefix |
||
42 | */ |
||
43 | public function __construct(Client $client, $prefix = null) |
||
48 | |||
49 | /** |
||
50 | * url encode a path |
||
51 | * |
||
52 | * @param string $path |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | protected function encodePath($path) |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public function getMetadata($path) |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function has($path) |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function read($path) |
||
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | public function write($path, $contents, Config $config) |
||
140 | |||
141 | /** |
||
142 | * {@inheritdoc} |
||
143 | */ |
||
144 | public function update($path, $contents, Config $config) |
||
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | public function rename($path, $newpath) |
||
171 | |||
172 | /** |
||
173 | * {@inheritdoc} |
||
174 | */ |
||
175 | public function delete($path) |
||
187 | |||
188 | /** |
||
189 | * {@inheritdoc} |
||
190 | */ |
||
191 | public function createDir($path, Config $config) |
||
202 | |||
203 | /** |
||
204 | * {@inheritdoc} |
||
205 | */ |
||
206 | public function deleteDir($dirname) |
||
210 | |||
211 | /** |
||
212 | * {@inheritdoc} |
||
213 | */ |
||
214 | public function listContents($directory = '', $recursive = false) |
||
239 | |||
240 | /** |
||
241 | * {@inheritdoc} |
||
242 | */ |
||
243 | public function getSize($path) |
||
247 | |||
248 | /** |
||
249 | * {@inheritdoc} |
||
250 | */ |
||
251 | public function getTimestamp($path) |
||
255 | |||
256 | /** |
||
257 | * {@inheritdoc} |
||
258 | */ |
||
259 | public function getMimetype($path) |
||
263 | |||
264 | /** |
||
265 | * Normalise a WebDAV repsonse object. |
||
266 | * |
||
267 | * @param array $object |
||
268 | * @param string $path |
||
269 | * |
||
270 | * @return array |
||
271 | */ |
||
272 | protected function normalizeObject(array $object, $path) |
||
289 | } |
||
290 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: