Skip to content

Commit

Permalink
Merge pull request #57 from kesselb/fix/53-directory-detection
Browse files Browse the repository at this point in the history
Make detection of directories compliant with rfc4918
  • Loading branch information
frankdejonge authored Dec 13, 2019
2 parents 9c69aec + f580900 commit d8cd5f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.9 - xxx

* Made detection of directories compliant with rfc4918 (#53).

## 1.0.8 - 2019-07-08

* Made some properties private to allow them to be overwritten so other types of WebDAV servers can be supported (#51).
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This is a Flysystem adapter for the WebDAV.
composer require league/flysystem-webdav
```

# Bootstrap
## Bootstrap

``` php
<?php
Expand Down
12 changes: 12 additions & 0 deletions src/WebDAVAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Sabre\DAV\Client;
use Sabre\DAV\Exception;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Xml\Property\ResourceType;
use Sabre\HTTP\HttpException;

class WebDAVAdapter extends AbstractAdapter
Expand All @@ -28,6 +29,7 @@ class WebDAVAdapter extends AbstractAdapter
'{DAV:}getcontenttype',
'{DAV:}getlastmodified',
'{DAV:}iscollection',
'{DAV:}resourcetype',
];

/**
Expand Down Expand Up @@ -400,8 +402,18 @@ protected function normalizeObject(array $object, $path)
return $result;
}

/**
* @param array $object
* @return bool
*/
protected function isDirectory(array $object)
{
if (isset($object['{DAV:}resourcetype'])) {
/** @var ResourceType $resourceType */
$resourceType = $object['{DAV:}resourcetype'];
return $resourceType->is('{DAV:}collection');
}

return isset($object['{DAV:}iscollection']) && $object['{DAV:}iscollection'] === '1';
}
}

0 comments on commit d8cd5f8

Please sign in to comment.