[Pkg-owncloud-commits] [php-sabredav] 04/148: {DAV:}supported-method-set
David Prévot
taffit at moszumanska.debian.org
Wed Apr 15 01:36:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 8df3759cb9f17891e9afd3f7aaae950e994993fa
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Mon Nov 17 18:08:55 2014 -0500
{DAV:}supported-method-set
---
lib/DAV/XML/Property/SupportedMethodSet.php | 128 ++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
diff --git a/lib/DAV/XML/Property/SupportedMethodSet.php b/lib/DAV/XML/Property/SupportedMethodSet.php
new file mode 100644
index 0000000..d64df47
--- /dev/null
+++ b/lib/DAV/XML/Property/SupportedMethodSet.php
@@ -0,0 +1,128 @@
+<?php
+
+namespace Sabre\DAV\XML\Property;
+
+use
+ Sabre\DAV,
+ Sabre\XML\Element,
+ Sabre\XML\Reader,
+ Sabre\XML\Writer,
+ Sabre\XML\Element\Elements;
+
+/**
+ * supported-method-set property.
+ *
+ * This property is defined in RFC3253, but since it's
+ * so common in other webdav-related specs, it is part of the core server.
+ *
+ * This property is defined here:
+ * http://tools.ietf.org/html/rfc3253#section-3.1.3
+ *
+ * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved.
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+class SupportedMethodSet implements Element {
+
+ /**
+ * List of methods
+ *
+ * @var string[]
+ */
+ protected $methods = [];
+
+ /**
+ * Creates the property
+ *
+ * Any reports passed in the constructor
+ * should be valid report-types in clark-notation.
+ *
+ * Either a string or an array of strings must be passed.
+ *
+ * @param string|string[] $methods
+ */
+ function __construct($methods = null) {
+
+ $this->methods = (array)$methods;
+
+ }
+
+ /**
+ * Returns the list of supported http methods.
+ *
+ * @return string[]
+ */
+ function getValue() {
+
+ return $this->methods;
+
+ }
+
+ /**
+ * Returns true or false if the property contains a specific method.
+ *
+ * @param string $methodName
+ * @return bool
+ */
+ function has($methodName) {
+
+ return in_array(
+ $methodName,
+ $this->methods
+ );
+
+ }
+
+ /**
+ * The serialize method is called during xml writing.
+ *
+ * It should use the $writer argument to encode this object into XML.
+ *
+ * Important note: it is not needed to create the parent element. The
+ * parent element is already created, and we only have to worry about
+ * attributes, child elements and text (if any).
+ *
+ * Important note 2: If you are writing any new elements, you are also
+ * responsible for closing them.
+ *
+ * @param Writer $writer
+ * @return void
+ */
+ function serializeXml(Writer $writer) {
+
+ foreach($this->getValue() as $val) {
+ $writer->startElement('{DAV:}supported-method');
+ $writer->writeAttribute('name', $val);
+ $writer->endElement();
+ }
+
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statictly, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * Important note 2: You are responsible for advancing the reader to the
+ * next element. Not doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @param Reader $reader
+ * @return mixed
+ */
+ static function deserializeXml(Reader $reader) {
+
+ throw new CannotDeserialize('This element does not have a deserializer');
+
+ }
+
+}
--
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