Documentation

Plugin extends ServerPlugin
in package

Locking plugin.

This plugin provides locking support to a WebDAV server. The easiest way to get started, is by hooking it up as such:

$lockBackend = new Sabre\DAV\Locks\Backend\File('./mylockdb'); $lockPlugin = new Sabre\DAV\Locks\Plugin($lockBackend); $server->addPlugin($lockPlugin);

Tags
copyright

Copyright (C) fruux GmbH (https://fruux.com/)

author

Evert Pot (http://evertpot.com/)

license

http://sabre.io/license/ Modified BSD License

Table of Contents

$locksBackend  : BackendInterface
locksBackend.
$server  : Server
server.
__construct()  : mixed
__construct.
afterUnbind()  : mixed
This method is called after a node is deleted.
getFeatures()  : array<string|int, mixed>
Returns a list of features for the HTTP OPTIONS Dav: header.
getHTTPMethods()  : array<string|int, mixed>
Use this method to tell the server this plugin defines additional HTTP methods.
getLocks()  : array<string|int, mixed>
Returns all lock information on a particular uri.
getPluginInfo()  : array<string|int, mixed>
Returns a bunch of meta-data about the plugin.
getPluginName()  : string
Returns a plugin name.
getSupportedReportSet()  : array<string|int, mixed>
Returns a list of reports this plugin supports.
getTimeoutHeader()  : int
Returns the contents of the HTTP Timeout header.
httpLock()  : bool
Locks an uri.
httpUnlock()  : mixed
Unlocks a uri.
initialize()  : mixed
Initializes the plugin.
lockNode()  : bool
Locks a uri.
propFind()  : mixed
This method is called after most properties have been found it allows us to add in any Lock-related properties.
unlockNode()  : bool
Unlocks a uri.
validateTokens()  : mixed
The validateTokens event is triggered before every request.
generateLockResponse()  : string
Generates the response for successful LOCK requests.
parseLockRequest()  : LockInfo
Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object.

Properties

Methods

afterUnbind()

This method is called after a node is deleted.

public afterUnbind(string $path) : mixed

We use this event to clean up any locks that still exist on the node.

Parameters
$path : string
Return values
mixed

getFeatures()

Returns a list of features for the HTTP OPTIONS Dav: header.

public getFeatures() : array<string|int, mixed>

In this case this is only the number 2. The 2 in the Dav: header indicates the server supports locks.

Return values
array<string|int, mixed>

getHTTPMethods()

Use this method to tell the server this plugin defines additional HTTP methods.

public getHTTPMethods(string $uri) : array<string|int, mixed>

This method is passed a uri. It should only return HTTP methods that are available for the specified uri.

Parameters
$uri : string
Return values
array<string|int, mixed>

getLocks()

Returns all lock information on a particular uri.

public getLocks(string $uri[, bool $returnChildLocks = false ]) : array<string|int, mixed>

This function should return an array with Sabre\DAV\Locks\LockInfo objects. If there are no locks on a file, return an empty array.

Additionally there is also the possibility of locks on parent nodes, so we'll need to traverse every part of the tree If the $returnChildLocks argument is set to true, we'll also traverse all the children of the object for any possible locks and return those as well.

Parameters
$uri : string
$returnChildLocks : bool = false
Return values
array<string|int, mixed>

getPluginInfo()

Returns a bunch of meta-data about the plugin.

public getPluginInfo() : array<string|int, mixed>

Providing this information is optional, and is mainly displayed by the Browser plugin.

The description key in the returned array may contain html and will not be sanitized.

Return values
array<string|int, mixed>

getPluginName()

Returns a plugin name.

public getPluginName() : string

Using this name other plugins will be able to access other plugins using Sabre\DAV\Server::getPlugin

Return values
string

getSupportedReportSet()

Returns a list of reports this plugin supports.

public getSupportedReportSet(string $uri) : array<string|int, mixed>

This will be used in the {DAV:}supported-report-set property. Note that you still need to subscribe to the 'report' event to actually implement them

Parameters
$uri : string
Return values
array<string|int, mixed>

getTimeoutHeader()

Returns the contents of the HTTP Timeout header.

public getTimeoutHeader() : int

The method formats the header into an integer.

Return values
int

httpLock()

Locks an uri.

public httpLock(RequestInterface $request, ResponseInterface $response) : bool

The WebDAV lock request can be operated to either create a new lock on a file, or to refresh an existing lock If a new lock is created, a full XML body should be supplied, containing information about the lock such as the type of lock (shared or exclusive) and the owner of the lock

If a lock is to be refreshed, no body should be supplied and there should be a valid If header containing the lock

Additionally, a lock can be requested for a non-existent file. In these case we're obligated to create an empty file as per RFC4918:S7.3

Parameters
$request : RequestInterface
$response : ResponseInterface
Return values
bool

httpUnlock()

Unlocks a uri.

public httpUnlock(RequestInterface $request, ResponseInterface $response) : mixed

This WebDAV method allows you to remove a lock from a node. The client should provide a valid locktoken through the Lock-token http header The server should return 204 (No content) on success

Parameters
$request : RequestInterface
$response : ResponseInterface
Return values
mixed

initialize()

Initializes the plugin.

public initialize(Server $server) : mixed

This method is automatically called by the Server class after addPlugin.

Parameters
$server : Server
Return values
mixed

lockNode()

Locks a uri.

public lockNode(string $uri, LockInfo $lockInfo) : bool

All the locking information is supplied in the lockInfo object. The object has a suggested timeout, but this can be safely ignored It is important that if the existing timeout is ignored, the property is overwritten, as this needs to be sent back to the client

Parameters
$uri : string
$lockInfo : LockInfo
Return values
bool

propFind()

This method is called after most properties have been found it allows us to add in any Lock-related properties.

public propFind(PropFind $propFind, INode $node) : mixed
Parameters
$propFind : PropFind
$node : INode
Return values
mixed

unlockNode()

Unlocks a uri.

public unlockNode(string $uri, LockInfo $lockInfo) : bool

This method removes a lock from a uri. It is assumed all the supplied information is correct and verified

Parameters
$uri : string
$lockInfo : LockInfo
Return values
bool

validateTokens()

The validateTokens event is triggered before every request.

public validateTokens(RequestInterface $request, mixed &$conditions) : mixed

It's a moment where this plugin can check all the supplied lock tokens in the If: header, and check if they are valid.

In addition, it will also ensure that it checks any missing lokens that must be present in the request, and reject requests without the proper tokens.

Parameters
$request : RequestInterface
$conditions : mixed
Return values
mixed

generateLockResponse()

Generates the response for successful LOCK requests.

protected generateLockResponse(LockInfo $lockInfo) : string
Parameters
$lockInfo : LockInfo
Return values
string

parseLockRequest()

Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object.

protected parseLockRequest(string $body) : LockInfo
Parameters
$body : string
Return values
LockInfo

Search results