[Pkg-owncloud-commits] [php-sabredav] 111/163: Migrated another two plugins to the new event system.
David Prévot
taffit at moszumanska.debian.org
Tue May 20 18:54:59 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag upstream/2.0.0_beta1
in repository php-sabredav.
commit b5f0a10ddb178c28d2689db2ba0f92edb73f3456
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Sat May 3 13:05:17 2014 -0400
Migrated another two plugins to the new event system.
---
lib/Sabre/CalDAV/Subscriptions/Plugin.php | 12 +++++++-----
lib/Sabre/DAV/Browser/GuessContentType.php | 29 ++++++++++++++---------------
lib/Sabre/DAV/PropFind.php | 17 ++++++++++++++++-
3 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/lib/Sabre/CalDAV/Subscriptions/Plugin.php b/lib/Sabre/CalDAV/Subscriptions/Plugin.php
index ffbac21..777cf27 100644
--- a/lib/Sabre/CalDAV/Subscriptions/Plugin.php
+++ b/lib/Sabre/CalDAV/Subscriptions/Plugin.php
@@ -3,6 +3,8 @@
namespace Sabre\CalDAV\Subscriptions;
use
+ Sabre\DAV\INode,
+ Sabre\DAV\PropFind,
Sabre\DAV\ServerPlugin,
Sabre\DAV\Server;
@@ -37,7 +39,7 @@ class Plugin extends ServerPlugin {
$server->propertyMap['{http://calendarserver.org/ns/}source'] =
'Sabre\\DAV\\Property\\Href';
- $server->on('afterGetProperties', [$this, 'afterGetProperties']);
+ $server->on('propFind', [$this, 'propFind'], 120);
}
@@ -51,7 +53,7 @@ class Plugin extends ServerPlugin {
*/
public function getFeatures() {
- return array('calendarserver-subscribed');
+ return ['calendarserver-subscribed'];
}
@@ -60,7 +62,7 @@ class Plugin extends ServerPlugin {
*
* @return void
*/
- public function afterGetProperties($path, &$properties, \Sabre\DAV\INode $node) {
+ public function propFind(PropFind $propFind, INode $node) {
// There's a bunch of properties that must appear as a self-closing
// xml-element. This event handler ensures that this will be the case.
@@ -72,8 +74,8 @@ class Plugin extends ServerPlugin {
foreach($props as $prop) {
- if (isset($properties[200][$prop])) {
- $properties[200][$prop] = '';
+ if ($propFind->getStatus($prop)===200) {
+ $propFind->set($prop, '', 200);
}
}
diff --git a/lib/Sabre/DAV/Browser/GuessContentType.php b/lib/Sabre/DAV/Browser/GuessContentType.php
index 7cc75a3..2cd04b9 100644
--- a/lib/Sabre/DAV/Browser/GuessContentType.php
+++ b/lib/Sabre/DAV/Browser/GuessContentType.php
@@ -4,7 +4,9 @@ namespace Sabre\DAV\Browser;
use
Sabre\HTTP\URLUtil,
- Sabre\DAV;
+ Sabre\DAV,
+ Sabre\DAV\PropFind,
+ Sabre\DAV\Inode;
/**
* GuessContentType plugin
@@ -56,30 +58,27 @@ class GuessContentType extends DAV\ServerPlugin {
// Using a relatively low priority (200) to allow other extensions
// to set the content-type first.
- $server->on('afterGetProperties',array($this,'afterGetProperties'),200);
+ $server->on('propFind', [$this,'propFind'], 200);
}
/**
- * Handler for teh afterGetProperties event
+ * Our PROPFIND handler
*
- * @param string $path
- * @param array $properties
+ * Here we set a contenttype, if the node didn't already have one.
+ *
+ * @param PropFind $propFind
+ * @param INode $node
* @return void
*/
- public function afterGetProperties($path, &$properties) {
-
- if (array_key_exists('{DAV:}getcontenttype', $properties[404])) {
+ public function propFind(PropFind $propFind, INode $node) {
- list(, $fileName) = URLUtil::splitPath($path);
- $contentType = $this->getContentType($fileName);
+ $propFind->handle('{DAV:}getcontenttype', function() use ($propFind) {
- if ($contentType) {
- $properties[200]['{DAV:}getcontenttype'] = $contentType;
- unset($properties[404]['{DAV:}getcontenttype']);
- }
+ list(, $fileName) = URLUtil::splitPath($propFind->getPath());
+ return $this->getContentType($fileName);
- }
+ });
}
diff --git a/lib/Sabre/DAV/PropFind.php b/lib/Sabre/DAV/PropFind.php
index 6737302..b918050 100644
--- a/lib/Sabre/DAV/PropFind.php
+++ b/lib/Sabre/DAV/PropFind.php
@@ -139,7 +139,7 @@ class PropFind {
* Returns the current value for a property.
*
* @param string $propertyName
- * @return void
+ * @return mixed
*/
public function get($propertyName) {
@@ -148,6 +148,21 @@ class PropFind {
}
/**
+ * Returns the current status code for a property name.
+ *
+ * If the property does not appear in the list of requested properties,
+ * null will be returned.
+ *
+ * @param string $propertyName
+ * @return int|null
+ */
+ public function getStatus($propertyName) {
+
+ return isset($this->result[$propertyName])?$this->result[$propertyName][0]:null;
+
+ }
+
+ /**
* Updates the path for this PROPFIND.
*
* @param string $path
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list