From 45285eca6a7edb353aaaa0cb28a8028984eacf61 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 1 Nov 2018 17:38:43 +0100 Subject: +infoBool / +infoInt Signed-off-by: Maxence Lange --- lib/public/FullTextSearch/Model/IndexDocument.php | 76 +++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'lib') diff --git a/lib/public/FullTextSearch/Model/IndexDocument.php b/lib/public/FullTextSearch/Model/IndexDocument.php index a73b702e506..f580a69a063 100644 --- a/lib/public/FullTextSearch/Model/IndexDocument.php +++ b/lib/public/FullTextSearch/Model/IndexDocument.php @@ -818,6 +818,82 @@ class IndexDocument implements JsonSerializable { return $this->info[$info]; } + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as int) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param int $value + * + * @return IndexDocument + */ + final public function setInfoInt(string $info, int $value): IndexDocument { + $this->info[$info] = $value; + + return $this; + } + + /** + * Get an information about a document. (int) + * + * @since 15.0.0 + * + * @param string $info + * @param int $default + * + * @return int + */ + final public function getInfoInt(string $info, int $default = 0): int { + if (!key_exists($info, $this->info)) { + return $default; + } + + return $this->info[$info]; + } + + /** + * Set some information about the original document that will be available + * to the front-end when displaying search result. (as bool) + * Because this information will not be indexed, this method can also be + * used to manage some data while filling the IndexDocument before its + * indexing. + * + * @since 15.0.0 + * + * @param string $info + * @param bool $value + * + * @return IndexDocument + */ + final public function setInfoBool(string $info, bool $value): IndexDocument { + $this->info[$info] = $value; + + return $this; + } + + /** + * Get an information about a document. (bool) + * + * @since 15.0.0 + * + * @param string $info + * @param bool $default + * + * @return bool + */ + final public function getInfoBool(string $info, bool $default = false): bool { + if (!key_exists($info, $this->info)) { + return $default; + } + + return $this->info[$info]; + } + /** * Get all info. * -- cgit v1.2.3 From 70b8c5672b0f4b267f298a5c702a6b82250413dd Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 1 Nov 2018 21:37:59 +0100 Subject: init some var Signed-off-by: Maxence Lange --- lib/public/FullTextSearch/Model/IndexDocument.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/public/FullTextSearch/Model/IndexDocument.php b/lib/public/FullTextSearch/Model/IndexDocument.php index f580a69a063..78679ac6225 100644 --- a/lib/public/FullTextSearch/Model/IndexDocument.php +++ b/lib/public/FullTextSearch/Model/IndexDocument.php @@ -57,10 +57,10 @@ class IndexDocument implements JsonSerializable { /** @var string */ - protected $id; + protected $id = ''; /** @var string */ - protected $providerId; + protected $providerId = ''; /** @var DocumentAccess */ protected $access; @@ -111,7 +111,7 @@ class IndexDocument implements JsonSerializable { protected $info = []; /** @var int */ - protected $contentEncoded; + protected $contentEncoded = 0; /** -- cgit v1.2.3