Permalink
Browse files

Encapsulate ReloadMessage for serialization

  • Loading branch information...
1 parent a6af455 commit 9a54be368506cc8d7bbd3372ff75b1a68f30b3c8 @cdujeu cdujeu committed May 24, 2016
@@ -0,0 +1,64 @@
+<?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\Message;
+
+use Pydio\Core\Controller\XMLWriter;
+use Pydio\Core\Http\Response\JSONSerializableResponseChunk;
+use Pydio\Core\Http\Response\XMLSerializableResponseChunk;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+
+class ReloadMessage implements XMLSerializableResponseChunk, JSONSerializableResponseChunk
+{
+ private $dataNode = '';
+ private $pendingSelection = '';
+
+ public function __construct($dataNode = "", $pendingSelection = ""){
+ $this->dataNode = $dataNode;
+ $this->pendingSelection = $pendingSelection;
+ }
+
+
+ /**
+ * @return mixed
+ */
+ public function jsonSerializableData()
+ {
+ return ['node'=> $this->dataNode, 'pendingSelection' => $this->pendingSelection];
+ }
+
+ /**
+ * @return string
+ */
+ public function jsonSerializableKey()
+ {
+ return 'reload';
+ }
+
+ /**
+ * @return string
+ */
+ public function toXML()
+ {
+ return XMLWriter::reloadDataNode($this->dataNode, $this->pendingSelection, false);
+ }
+}
@@ -29,12 +29,11 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\NodesList;
use Pydio\Access\Core\Model\UserSelection;
+use Pydio\Core\Http\Message\ReloadMessage;
use Pydio\Core\Http\Message\UserMessage;
-use Pydio\Core\Http\Message\XMLMessage;
use Pydio\Core\Http\Response\SerializableResponseStream;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
-use Pydio\Core\Controller\XMLWriter;
use Pydio\Core\PluginFramework\PluginsService;
use ShareCenter;
use Zend\Diactoros\Response\EmptyResponse;
@@ -160,7 +159,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
$x->addChunk(new UserMessage($out, LOG_LEVEL_INFO));
}
}
- $x->addChunk(new XMLMessage(XMLWriter::reloadDataNode("", "", false)));
+ $x->addChunk(new ReloadMessage());
break;
case "clear_expired" :
@@ -172,7 +171,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
$deleted = $shareCenter->getShareStore()->clearExpiredFiles(true);
if (count($deleted)) {
$x->addChunk(new UserMessage(sprintf($mess["user_dash.23"], count($deleted)."")));
- $x->addChunk(new XMLMessage(XMLWriter::reloadDataNode("", "", false)));
+ $x->addChunk(new ReloadMessage());
} else {
$x->addChunk(new UserMessage($mess["user_dash.24"]));
}
@@ -187,7 +186,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
foreach ($elements as $element) {
PublicletCounter::reset(str_replace(".php", "", basename($element)));
}
- $x->addChunk(new XMLMessage(XMLWriter::reloadDataNode("", "", false)));
+ $x->addChunk(new ReloadMessage());
break;
default:

0 comments on commit 9a54be3

Please sign in to comment.