Permalink
Browse files

Add new interface to detect if content should be wrapped in xml or not.

  • Loading branch information...
1 parent 76eab67 commit 05d7a14e29c86246ab43916ec17bd7e3777e6d5e @cdujeu cdujeu committed May 11, 2016
@@ -86,14 +86,22 @@ protected function serializeData($data, $serializer){
}
return json_encode($buffer);
}else if($serializer == self::SERIALIZER_TYPE_XML){
+ $wrap = true;
$buffer = "";
foreach ($data as $serializableItem){
if(!$serializableItem instanceof XMLSerializableResponseChunk){
continue;
}
$buffer .= $serializableItem->toXML();
+ if($serializableItem instanceof XMLDocSerializableResponseChunk){
+ $wrap = false;
+ }
+ }
+ if($wrap){
+ return XMLWriter::wrapDocument($buffer);
+ }else{
+ return $buffer;
}
- return XMLWriter::wrapDocument($buffer);
}
return "";
}
@@ -0,0 +1,28 @@
+<?php
+/*
+ * Copyright 2007-2015 Abstrium <contact (at) pydio.com>
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The latest code can be found at <http://pyd.io/>.
+ */
+namespace Pydio\Core\Http;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+interface XMLDocSerializableResponseChunk extends XMLSerializableResponseChunk
+{
+
+}
@@ -23,9 +23,9 @@
defined('AJXP_EXEC') or die('Access not allowed');
use Pydio\Core\Controller\XMLWriter;
-use Pydio\Core\Http\XMLSerializableResponseChunk;
+use Pydio\Core\Http\XMLDocSerializableResponseChunk;
-class NodesList implements XMLSerializableResponseChunk
+class NodesList implements XMLDocSerializableResponseChunk
{
/**

0 comments on commit 05d7a14

Please sign in to comment.