[CORE][Cache] Use hashmaps to store language related items
This commit is contained in:
parent
2eb31952bc
commit
68c6dd1ba9
@ -361,14 +361,14 @@ class Actor extends Entity
|
|||||||
public function getPreferredLanguageChoices(?self $context = null): array
|
public function getPreferredLanguageChoices(?self $context = null): array
|
||||||
{
|
{
|
||||||
$id = $context?->getId() ?? $this->getId();
|
$id = $context?->getId() ?? $this->getId();
|
||||||
return Cache::get(
|
return Cache::getHashMap(
|
||||||
'actor-' . $this->getId() . '-langs' . (!\is_null($context) ? '-' . $context->getId() : ''),
|
'actor-' . $this->getId() . '-langs' . (!\is_null($context) ? '-' . $context->getId() : ''),
|
||||||
fn () => array_merge( // TODO replace with F\transform
|
fn () => array_merge( // TODO replace with F\transform
|
||||||
...F\map(DB::dql(
|
...F\map(DB::dql(
|
||||||
'select l from actor_language al join language l with al.language_id = l.id where al.actor_id = :id order by al.order ASC',
|
'select l from actor_language al join language l with al.language_id = l.id where al.actor_id = :id order by al.order ASC',
|
||||||
['id' => $id],
|
['id' => $id],
|
||||||
), fn ($l) => $l->toChoiceFormat()),
|
), fn ($l) => $l->toChoiceFormat()),
|
||||||
) ?: DB::findOneBy('language', ['locale' => Common::config('site', 'language')])->toChoiceFormat(),
|
) ?: Cache::getHashMapKey('languages', Common::config('site', 'language'))->toChoiceFormat(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user