diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2017-12-29 14:19:50 +0300 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2017-12-29 14:19:50 +0300 |
commit | 49d6bd01f3ff65401932634f7a1386fd754e8fd8 (patch) | |
tree | dafa2de2a7f84b99e5ca950be76891f507132b7d /lib/Model | |
parent | eae4aa417ebcc13a526620b32fdc71ab2554967b (diff) |
cleaning excerpt
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model')
-rw-r--r-- | lib/Model/IndexDocument.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Model/IndexDocument.php b/lib/Model/IndexDocument.php index 00cdfdb..01fabcb 100644 --- a/lib/Model/IndexDocument.php +++ b/lib/Model/IndexDocument.php @@ -302,6 +302,8 @@ class IndexDocument implements \JsonSerializable { * @return $this */ public function setExcerpts($excerpts) { + $excerpts = array_map([$this, 'cleanExcerpt'], $excerpts); + $this->excerpts = $excerpts; return $this; @@ -318,9 +320,24 @@ class IndexDocument implements \JsonSerializable { * @param string $excerpt */ public function addExcerpt($excerpt) { + $excerpt = $this->cleanExcerpt($excerpt); + $this->excerpts[] = $excerpt; } + /** + * @param $excerpt + * + * @return mixed + */ + public function cleanExcerpt($excerpt) { + $excerpt = str_replace("\\n", ' ', $excerpt); + $excerpt = str_replace("\\r", ' ', $excerpt); + $excerpt = str_replace("\n", ' ', $excerpt); + $excerpt = str_replace("\r", ' ', $excerpt); + + return $excerpt; + } /** * @param string $score |