aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-01 11:37:39 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-03 18:24:33 +0100
commitcc92d5a293e85a8d67ed30e48bcad09fc03325f5 (patch)
treedc8f2a98ea92505982c0d5241bc8b8442a459363 /lib
parentfc57f60ece173d3f3b13a2d88e8b5db83ea6427e (diff)
downloadnextcloud-server-cc92d5a293e85a8d67ed30e48bcad09fc03325f5.tar.gz
nextcloud-server-cc92d5a293e85a8d67ed30e48bcad09fc03325f5.zip
Allow unified search results to have attributes
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/public/Search/SearchResultEntry.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/public/Search/SearchResultEntry.php b/lib/public/Search/SearchResultEntry.php
index b661ced5014..347c3fcd289 100644
--- a/lib/public/Search/SearchResultEntry.php
+++ b/lib/public/Search/SearchResultEntry.php
@@ -83,6 +83,13 @@ class SearchResultEntry implements JsonSerializable {
protected $rounded;
/**
+ * @var string[]
+ * @psalm-var array<string, string>
+ * @since 20.0.0
+ */
+ protected $attributes = [];
+
+ /**
* @param string $thumbnailUrl a relative or absolute URL to the thumbnail or icon of the entry
* @param string $title a main title of the entry
* @param string $subline the secondary line of the entry
@@ -107,6 +114,19 @@ class SearchResultEntry implements JsonSerializable {
}
/**
+ * Add optional attributes to the result entry, e.g. an ID or some other
+ * context information that can be read by the client application
+ *
+ * @param string $key
+ * @param string $value
+ *
+ * @since 20.0.0
+ */
+ public function addAttribute(string $key, string $value): void {
+ $this->attributes[$key] = $value;
+ }
+
+ /**
* @return array
*
* @since 20.0.0
@@ -119,6 +139,7 @@ class SearchResultEntry implements JsonSerializable {
'resourceUrl' => $this->resourceUrl,
'icon' => $this->icon,
'rounded' => $this->rounded,
+ 'attributes' => $this->attributes,
];
}
}