From 1b9ab6064d06c4658192a65a8b33a679d718d2d5 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 14 Jun 2024 18:54:06 -0500 Subject: [PATCH] Internal: NameConvention service use the env platform language --- src/CoreBundle/Component/Utils/NameConvention.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CoreBundle/Component/Utils/NameConvention.php b/src/CoreBundle/Component/Utils/NameConvention.php index b43b00ba15..2eaeaba12f 100644 --- a/src/CoreBundle/Component/Utils/NameConvention.php +++ b/src/CoreBundle/Component/Utils/NameConvention.php @@ -7,15 +7,18 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\Component\Utils; use Chamilo\CoreBundle\Entity\User; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\RequestStack; class NameConvention { protected RequestStack $requestStack; + private ParameterBagInterface $parameterBag; - public function __construct(RequestStack $requestStack) + public function __construct(RequestStack $requestStack, ParameterBagInterface $parameterBag) { $this->requestStack = $requestStack; + $this->parameterBag = $parameterBag; } public function getPersonName(User $user): string @@ -35,7 +38,7 @@ class NameConvention public function getFormat(): array { - $locale = $this->requestStack->getCurrentRequest()->getLocale(); + $locale = $this->requestStack->getCurrentRequest()?->getLocale() ?? $this->parameterBag->get('locale'); $format = $this->getDefaultList()[$locale] ?? null; if (null === $format) {