Browse Source
Allow unified search results to have attributes
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/24474/head
Christoph Wurst
5 years ago
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with
21 additions and
0 deletions
-
lib/public/Search/SearchResultEntry.php
|
|
|
@ -82,6 +82,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 |
|
|
|
@ -106,6 +113,19 @@ class SearchResultEntry implements JsonSerializable { |
|
|
|
$this->rounded = $rounded; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 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 |
|
|
|
* |
|
|
|
@ -119,6 +139,7 @@ class SearchResultEntry implements JsonSerializable { |
|
|
|
'resourceUrl' => $this->resourceUrl, |
|
|
|
'icon' => $this->icon, |
|
|
|
'rounded' => $this->rounded, |
|
|
|
'attributes' => $this->attributes, |
|
|
|
]; |
|
|
|
} |
|
|
|
} |