From 3909fd9d0a26b9a5409480ef7b2431a03f708c0d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 23 Feb 2022 15:58:04 +0100 Subject: [PATCH] wip #5122 @0.25 --- src/Document.php | 24 +++++++++++++++++++++++- src/Index.php | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Document.php b/src/Document.php index 9de558b..3352154 100644 --- a/src/Document.php +++ b/src/Document.php @@ -19,6 +19,11 @@ class Document */ protected $title = ''; + /** + * @var string + */ + protected $displayedTitle=''; + /** * @var string */ @@ -157,6 +162,23 @@ class Document $this->keywords = $keywords; } + + /** + * @return string + */ + public function getDisplayedTitle(): string + { + return $this->displayedTitle?:$this->getTitle(); + } + + /** + * @param string $displayedTitle + */ + public function setDisplayedTitle(string $displayedTitle): void + { + $this->displayedTitle = $displayedTitle; + } + /** * @return array[] */ @@ -170,7 +192,7 @@ class Document */ public function getIndividualDocData() { - return ['id' => $this->getId(), 'type' => $this->getType(), 'thumb' => $this->getThumb(), 'title' => $this->getTitle(), 'url' => $this->getUrl(), 'text' => $this->getText(), 'keywords' => $this->getKeywords()]; + return ['id' => $this->getId(), 'type' => $this->getType(), 'thumb' => $this->getThumb(), 'title' => $this->getTitle(), 'url' => $this->getUrl(), 'text' => $this->getText(), 'keywords' => $this->getKeywords(),'displayedTitle'=>$this->getDisplayedTitle()]; } } \ No newline at end of file diff --git a/src/Index.php b/src/Index.php index 12a73be..09a8e4f 100644 --- a/src/Index.php +++ b/src/Index.php @@ -63,7 +63,7 @@ class Index implements ShouldQueue, ShouldBeUnique file_put_contents($this->getOutput(), $this->generateCode()); } - public function generateCode($fields = 'title,text,keywords', $storeFields = 'id,title,text,type,url,thumb',$prefix=true,$fuzzy=0.2) + public function generateCode($fields = 'title,text,keywords', $storeFields = 'id,displayedTitle,text,type,url,thumb',$prefix=true,$fuzzy=0.2) { $res = []; foreach ($this->documents as $document) { -- 2.39.5