From 63bf93d7f371a1ad6d41a253e394a95e18c19a5a Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sun, 5 Dec 2021 21:03:13 +0000 Subject: [PATCH] [CORE][Entity][Note] Language can be null --- src/Entity/Note.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Entity/Note.php b/src/Entity/Note.php index a8dcba88e6..1e3ace3a77 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -85,9 +85,6 @@ class Note extends Entity return $this->content_type; } - /** - * @return Note - */ public function setContentType(string $content_type): self { $this->content_type = $content_type; @@ -221,14 +218,14 @@ class Note extends Entity return Cache::get("note-{$note_id}", fn () => DB::findOneBy('note', ['id' => $note_id])); } - public function getNoteLanguageShortDisplay(): string + public function getNoteLanguageShortDisplay(): ?string { - return Language::getById($this->language_id)->getShortDisplay(); + return !is_null($this->language_id) ? Language::getById($this->language_id)->getShortDisplay() : null; } - public function getLanguageLocale(): string + public function getLanguageLocale(): ?string { - return Language::getById($this->language_id)->getLocale(); + return !is_null($this->language_id) ? Language::getById($this->language_id)->getLocale() : null; } public static function getAllNotesByActor(Actor $actor): array