[ENTITY][NoteTag][Language] Add convinience cache getters
This commit is contained in:
parent
a47a01abee
commit
4f669d4e01
@ -126,6 +126,11 @@ class Language extends Entity
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getFromNote(Note $note): self
|
||||||
|
{
|
||||||
|
return self::getFromId($note->getLanguageId());
|
||||||
|
}
|
||||||
|
|
||||||
public static function getLanguageChoices(): array
|
public static function getLanguageChoices(): array
|
||||||
{
|
{
|
||||||
$langs = Cache::getHashMap(
|
$langs = Cache::getHashMap(
|
||||||
|
@ -110,9 +110,17 @@ class NoteTag extends Entity
|
|||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
// }}} Autocode
|
// }}} Autocode
|
||||||
|
|
||||||
|
public static function cacheKey(int|Note $note_id)
|
||||||
|
{
|
||||||
|
if (!\is_int($note_id)) {
|
||||||
|
$note_id = $note_id->getId();
|
||||||
|
}
|
||||||
|
return "note-tags-{$note_id}";
|
||||||
|
}
|
||||||
|
|
||||||
public static function getFromNoteId(int $note_id): array
|
public static function getFromNoteId(int $note_id): array
|
||||||
{
|
{
|
||||||
return Cache::getList("note-tags-{$note_id}", fn () => DB::dql('select nt from note_tag nt join note n with n.id = nt.note_id where n.id = :id', ['id' => $note_id]));
|
return Cache::getList(self::cacheKey($note_id), fn () => DB::dql('select nt from note_tag nt join note n with n.id = nt.note_id where n.id = :id', ['id' => $note_id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUrl(?Actor $actor = null): string
|
public function getUrl(?Actor $actor = null): string
|
||||||
|
Loading…
Reference in New Issue
Block a user