fruux/sabre-dav — pull request #429 by evert (2014-04-05 06:30:21+00:00)
Title: Property refactor

Implemented a new property updating system. The existing system had some limitations that made it impossible to create a generic 'dead property storage', which is something we'd like to add in the future.

Any method that deals with updating of properties, now receives a `PropPatch` object that contains all the information about a single property-update operation.

To do the actual updating of properties, you must tell the PropPatch object that you promise to handle one or more properties, which looks a bit like this:

```php
$propPatch->handle('{DAV:}displayname', function($value) {

// $value is a string that we should store somewhere
return true;

});
```

If there's a property in the property-update request that does not have a handler, the entire request automatically fails and none of the other handlers are called.

To create our dead property storage, we just need to subscribe to the 'propPatch' event, and call `handleRemaining`:

```php

$server->on('propPatch', function($uri, PropPatch $propPatch) {

$propPatch->handleRemaining(function($mutations) {

// $mutations is a key->value list with properties that are being updated.
// the $value is null if the property is supposed to be deleted.
return true;
});

});

```