Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Model
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-01-05 16:40:25 +0300
committerMaxence Lange <maxence@artificial-owl.com>2018-01-05 16:40:25 +0300
commitd46b76f0ec8f241d174c90f94c35ace97f743fdc (patch)
tree30c96e88eeb98bc3b9086facf1abfeda29d8bb1b /lib/Model
parent6ac881c3da6e2e6d2f77a7179cce530f2f9f59f4 (diff)
improve search request with tags+options
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model')
-rw-r--r--lib/Model/SearchRequest.php65
1 files changed, 63 insertions, 2 deletions
diff --git a/lib/Model/SearchRequest.php b/lib/Model/SearchRequest.php
index 6b123d5..31a25a2 100644
--- a/lib/Model/SearchRequest.php
+++ b/lib/Model/SearchRequest.php
@@ -45,6 +45,13 @@ class SearchRequest implements \JsonSerializable {
/** @var string */
private $author;
+ /** @var array */
+ private $tags;
+
+ /** @var array */
+ private $options;
+
+
/**
* SearchRequest constructor.
*/
@@ -142,13 +149,65 @@ class SearchRequest implements \JsonSerializable {
/**
* @return array
*/
+ public function getOptions() {
+ return $this->options;
+ }
+
+ /**
+ * @param array $options
+ */
+ public function setOptions($options) {
+ $this->options = $options;
+ }
+
+ /**
+ * @param string $option
+ *
+ * @return mixed|string
+ */
+ public function getOption($option) {
+ if (array_key_exists($option, $this->options)) {
+ return $this->options[$option];
+ }
+
+ return '';
+ }
+
+
+ /**
+ * @param string $tag
+ */
+ public function addTag($tag) {
+ $this->tags[] = $tag;
+ }
+
+ /**
+ * @return array
+ */
+ public function getTags() {
+ return $this->tags;
+ }
+
+ /**
+ * @param array $tags
+ */
+ public function setTags($tags) {
+ $this->tags = $tags;
+ }
+
+
+ /**
+ * @return array
+ */
public function jsonSerialize() {
return [
'providers' => $this->getProviders(),
'author' => $this->getAuthor(),
'search' => $this->getSearch(),
'page' => $this->getPage(),
- 'size' => $this->getSize()
+ 'size' => $this->getSize(),
+ 'options' => $this->getOptions(),
+ 'tags' => $this->getTags()
];
}
@@ -170,10 +229,12 @@ class SearchRequest implements \JsonSerializable {
public static function fromArray($arr) {
$request = new SearchRequest();
$request->setProviders($arr['providers']);
- $request->setAuthor($arr['author']);
+ $request->setAuthor(MiscService::get($arr, 'author', ''));
$request->setSearch(MiscService::get($arr, 'search', ''));
$request->setPage(MiscService::get($arr, 'page', 0));
$request->setSize(MiscService::get($arr, 'size', 10));
+ $request->setOptions(MiscService::get($arr, 'options', []));
+ $request->setTags(MiscService::get($arr, 'tags', []));
return $request;
}