Methods |
public
|
__construct(Tree|INode|array|null $treeOrNode = null, Sapi $sapi = null)
Sets up the server.
Sets up the server.
If a Sabre\DAV\Tree object is passed as an argument, it will
use it as the directory tree. If a Sabre\DAV\INode is passed, it
will create a Sabre\DAV\Tree and use the node as the root.
If nothing is passed, a Sabre\DAV\SimpleCollection is created in
a Sabre\DAV\Tree.
If an array is passed, we automatically create a root node, and use
the nodes in the array as top-level children.
Parameters
$treeOrNode |
The tree object
|
Throws
|
#
|
public
|
start()
Starts the DAV Server.
|
#
|
public
|
exec()
Alias of start().
|
#
|
public
|
setBaseUri(string $uri)
Sets the base server uri.
Sets the base server uri.
|
#
|
public
|
getBaseUri(): string
Returns the base responding uri.
Returns the base responding uri.
|
#
|
public
|
guessBaseUri(): string
This method attempts to detect the base uri.
Only the PATH_INFO variable is considered.
This method attempts to detect the base uri.
Only the PATH_INFO variable is considered.
If this variable is not set, the root (/) is assumed.
|
#
|
public
|
addPlugin(ServerPlugin $plugin)
Adds a plugin to the server.
Adds a plugin to the server.
For more information, console the documentation of Sabre\DAV\ServerPlugin
|
#
|
public
|
getPlugin(string $name): ServerPlugin
Returns an initialized plugin by it's name.
Returns an initialized plugin by it's name.
This function returns null if the plugin was not found.
|
#
|
public
|
getPlugins(): array
Returns all plugins.
|
#
|
public
|
getLogger(): LoggerInterface
Returns the PSR-3 logger object.
Returns the PSR-3 logger object.
|
#
|
public
|
invokeMethod(RequestInterface $request, ResponseInterface $response, bool $sendResponse = true)
Handles a http request, and execute a method based on its name.
Handles a http request, and execute a method based on its name.
Parameters
$sendResponse |
whether to send the HTTP response to the DAV client
|
|
#
|
public
|
getAllowedMethods(string $path): array
Returns an array with all the supported HTTP methods for a specific uri.
Returns an array with all the supported HTTP methods for a specific uri.
|
#
|
public
|
getRequestUri(): string
Gets the uri for the request, keeping the base uri into consideration.
Gets the uri for the request, keeping the base uri into consideration.
|
#
|
public
|
calculateUri(string $uri): string
Turns a URI such as the REQUEST_URI into a local path.
Turns a URI such as the REQUEST_URI into a local path.
This method:
- strips off the base path
- normalizes the path
- uri-decodes the path
Throws
|
#
|
public
|
getHTTPDepth(mixed $default = self::DEPTH_INFINITY): int
Returns the HTTP depth header.
Returns the HTTP depth header.
This method returns the contents of the HTTP depth request header. If the depth header was 'infinity' it will return the Sabre\DAV\Server::DEPTH_INFINITY object
It is possible to supply a default depth value, which is used when the depth header has invalid content, or is completely non-existent
|
#
|
public
|
getHTTPRange(): int[]|null
Returns the HTTP range header.
Returns the HTTP range header.
This method returns null if there is no well-formed HTTP range request
header or array($start, $end).
The first number is the offset of the first byte in the range.
The second number is the offset of the last byte in the range.
If the second offset is null, it should be treated as the offset of the last byte of the entity
If the first offset is null, the second offset should be used to retrieve the last x bytes of the entity
|
#
|
public
|
getHTTPPrefer(): array
Returns the HTTP Prefer header information.
Returns the HTTP Prefer header information.
The prefer header is defined in:
http://tools.ietf.org/html/draft-snell-http-prefer-14
This method will return an array with options.
Currently, the following options may be returned:
[
'return-asynch' => true,
'return-minimal' => true,
'return-representation' => true,
'wait' => 30,
'strict' => true,
'lenient' => true,
]
This method also supports the Brief header, and will also return
'return-minimal' if the brief header was set to 't'.
For the boolean options, false will be returned if the headers are not
specified. For the integer options it will be 'null'.
|
#
|
public
|
getCopyAndMoveInfo(RequestInterface $request): array
Returns information about Copy and Move requests.
Returns information about Copy and Move requests.
This function is created to help getting information about the source and the destination for the
WebDAV MOVE and COPY HTTP request. It also validates a lot of information and throws proper exceptions
The returned value is an array with the following keys:
- destination - Destination path
- destinationExists - Whether or not the destination is an existing url (and should therefore be overwritten)
Throws
|
#
|
public
|
getProperties(string $path, array $propertyNames): array
Returns a list of properties for a path.
Returns a list of properties for a path.
This is a simplified version getPropertiesForPath. If you aren't
interested in status codes, but you just want to have a flat list of
properties, use this method.
Please note though that any problems related to retrieving properties,
such as permission issues will just result in an empty array being
returned.
|
#
|
public
|
getPropertiesForChildren(string $path, array $propertyNames): array
A kid-friendly way to fetch properties for a node's children.
A kid-friendly way to fetch properties for a node's children.
The returned array will be indexed by the path of the of child node.
Only properties that are actually found will be returned.
The parent node will not be returned.
|
#
|
public
|
getHTTPHeaders(string $path): array
Returns a list of HTTP headers for a particular resource.
Returns a list of HTTP headers for a particular resource.
The generated http headers are based on properties provided by the
resource. The method basically provides a simple mapping between
DAV property and HTTP header.
The headers are intended to be used for HEAD and GET requests.
|
#
|
public
|
getPropertiesForPath(string $path, array $propertyNames = [], int $depth = 0): array
Returns a list of properties for a given path.
Returns a list of properties for a given path.
The path that should be supplied should have the baseUrl stripped out
The list of properties should be supplied in Clark notation. If the list is empty
'allprops' is assumed.
If a depth of 1 is requested child elements will also be returned.
Deprecated
Use getPropertiesIteratorForPath() instead (as it's more memory efficient)
|
#
|
public
|
getPropertiesIteratorForPath(string $path, array $propertyNames = [], int $depth = 0): Iterator
Returns a list of properties for a given path.
Returns a list of properties for a given path.
The path that should be supplied should have the baseUrl stripped out
The list of properties should be supplied in Clark notation. If the list is empty
'allprops' is assumed.
If a depth of 1 is requested child elements will also be returned.
|
#
|
public
|
getPropertiesForMultiplePaths(array $paths, array $propertyNames = []): array
Returns a list of properties for a list of paths.
Returns a list of properties for a list of paths.
The path that should be supplied should have the baseUrl stripped out
The list of properties should be supplied in Clark notation. If the list is empty
'allprops' is assumed.
The result is returned as an array, with paths for it's keys.
The result may be returned out of order.
|
#
|
public
|
getPropertiesByNode(PropFind $propFind, INode $node): bool
Determines all properties for a node.
Determines all properties for a node.
This method tries to grab all properties for a node. This method is used
internally getPropertiesForPath and a few others.
It could be useful to call this, if you already have an instance of your
target node and simply want to run through the system to get a correct
list of properties.
|
#
|
public
|
createFile(string $uri, resource $data, string &$etag = null): bool
This method is invoked by sub-systems creating a new file.
This method is invoked by sub-systems creating a new file.
Currently this is done by HTTP PUT and HTTP LOCK (in the Locks_Plugin).
It was important to get this done through a centralized function,
allowing plugins to intercept this using the beforeCreateFile event.
This method will return true if the file was actually created
|
#
|
public
|
updateFile(string $uri, resource $data, string &$etag = null): bool
This method is invoked by sub-systems updating a file.
This method is invoked by sub-systems updating a file.
This method will return true if the file was actually updated
|
#
|
public
|
createDirectory(string $uri)
This method is invoked by sub-systems creating a new directory.
This method is invoked by sub-systems creating a new directory.
|
#
|
public
|
createCollection(string $uri, MkCol $mkCol): array|null
Use this method to create a new collection.
Use this method to create a new collection.
Parameters
|
#
|
public
|
updateProperties(string $path, array $properties): array
This method updates a resource's properties.
This method updates a resource's properties.
The properties array must be a list of properties. Array-keys are
property names in clarknotation, array-values are it's values.
If a property must be deleted, the value should be null.
Note that this request should either completely succeed, or
completely fail.
The response is an array with properties for keys, and http status codes
as their values.
|
#
|
public
|
checkPreconditions(RequestInterface $request, ResponseInterface $response): bool
This method checks the main HTTP preconditions.
This method checks the main HTTP preconditions.
Currently these are:
- If-Match
- If-None-Match
- If-Modified-Since
- If-Unmodified-Since
The method will return true if all preconditions are met
The method will return false, or throw an exception if preconditions
failed. If false is returned the operation should be aborted, and
the appropriate HTTP response headers are already set.
Normally this method will throw 412 Precondition Failed for failures
related to If-None-Match, If-Match and If-Unmodified Since. It will
set the status to 304 Not Modified for If-Modified_since.
|
#
|
public
|
getIfConditions(RequestInterface $request): array
This method is created to extract information from the WebDAV HTTP 'If:' header.
This method is created to extract information from the WebDAV HTTP 'If:' header.
The If header can be quite complex, and has a bunch of features. We're using a regex to extract all relevant information
The function will return an array, containing structs with the following keys
- uri - the uri the condition applies to.
- tokens - The lock token. another 2 dimensional array containing 3 elements
Example 1:
If: (opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2)
Would result in:
[
[
'uri' => '/request/uri',
'tokens' => [
[
[
'negate' => false,
'token' => 'opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2',
'etag' => ""
]
]
],
]
]
Example 2:
If: </path/> (Not opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2 ["Im An ETag"]) (["Another ETag"]) </path2/> (Not ["Path2 ETag"])
Would result in:
[
[
'uri' => 'path',
'tokens' => [
[
[
'negate' => true,
'token' => 'opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2',
'etag' => '"Im An ETag"'
],
[
'negate' => false,
'token' => '',
'etag' => '"Another ETag"'
]
]
],
],
[
'uri' => 'path2',
'tokens' => [
[
[
'negate' => true,
'token' => '',
'etag' => '"Path2 ETag"'
]
]
],
],
]
|
#
|
public
|
getResourceTypeForNode(INode $node): array
Returns an array with resourcetypes for a node.
Returns an array with resourcetypes for a node.
|
#
|
public
|
generateMultiStatus(array|Traversable $fileProperties, bool $strip404s = false): callable|string
Returns a callback generating a WebDAV propfind response body based on a list of nodes.
Returns a callback generating a WebDAV propfind response body based on a list of nodes.
If 'strip404s' is set to true, all 404 responses will be removed.
Parameters
$fileProperties |
The list with nodes
|
|
#
|