]> _ Git - cubist_minisearch.git/commitdiff
wip #5122 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 23 Feb 2022 14:58:04 +0000 (15:58 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 23 Feb 2022 14:58:04 +0000 (15:58 +0100)
src/Document.php
src/Index.php

index 9de558b0bf68a78a3a87999bd10663afbcace44c..3352154dd66659b66e927a9d64c6541dfe4e6350 100644 (file)
@@ -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
index 12a73beacd6f3e986adebcc315c5f90df9d66533..09a8e4fb0c5ea812d06a1aa3ea4b96f3e67aec1e 100644 (file)
@@ -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) {