X-Git-Url: https://git.rapsys.eu/userbundle/blobdiff_plain/89c69fc76c57fd4a17ba68b0e8889c1844fe5701..32b9912accd3c35c7830a068af7de189bdde7136:/Controller/AbstractController.php diff --git a/Controller/AbstractController.php b/Controller/AbstractController.php index eecc2d0..8a0a2c8 100644 --- a/Controller/AbstractController.php +++ b/Controller/AbstractController.php @@ -66,6 +66,11 @@ abstract class AbstractController extends BaseAbstractController implements Serv */ protected int $page; + /** + * Request instance + */ + protected Request $request; + /** * Abstract constructor * @@ -212,13 +217,13 @@ abstract class AbstractController extends BaseAbstractController implements Serv $pathInfo = $this->router->getContext()->getPathInfo(); //Iterate on locales excluding current one - foreach(($locales = array_keys($this->config['languages'])) as $locale) { + foreach(($locales = array_keys($this->config['default']['languages'])) as $locale) { //Set titles $titles = []; //Iterate on other locales foreach(array_diff($locales, [$locale]) as $other) { - $titles[$other] = $this->translator->trans($this->config['languages'][$locale], [], null, $other); + $titles[$other] = $this->translator->trans($this->config['default']['languages'][$locale], [], null, $other); } //Retrieve route matching path @@ -233,25 +238,25 @@ abstract class AbstractController extends BaseAbstractController implements Serv //With current locale if ($locale == $this->locale) { //Set locale locales context - $this->config[$tag][$view]['context']['head']['canonical'] = $this->router->generate($name, ['_locale' => $locale]+$route, UrlGeneratorInterface::ABSOLUTE_URL); + $this->config[$tag][$view]['context']['canonical'] = $this->router->generate($name, ['_locale' => $locale]+$route, UrlGeneratorInterface::ABSOLUTE_URL); } else { //Set locale locales context - $this->config[$tag][$view]['context']['head']['alternates'][$locale] = [ + $this->config[$tag][$view]['context']['alternates'][$locale] = [ 'absolute' => $this->router->generate($name, ['_locale' => $locale]+$route, UrlGeneratorInterface::ABSOLUTE_URL), 'relative' => $this->router->generate($name, ['_locale' => $locale]+$route), 'title' => implode('/', $titles), - 'translated' => $this->translator->trans($this->config['languages'][$locale], [], null, $locale) + 'translated' => $this->translator->trans($this->config['default']['languages'][$locale], [], null, $locale) ]; } //Add shorter locale - if (empty($this->config[$tag][$view]['context']['head']['alternates'][$slocale = substr($locale, 0, 2)])) { + if (empty($this->config[$tag][$view]['context']['alternates'][$slocale = substr($locale, 0, 2)])) { //Add shorter locale - $this->config[$tag][$view]['context']['head']['alternates'][$slocale] = [ + $this->config[$tag][$view]['context']['alternates'][$slocale] = [ 'absolute' => $this->router->generate($name, ['_locale' => $locale]+$route, UrlGeneratorInterface::ABSOLUTE_URL), 'relative' => $this->router->generate($name, ['_locale' => $locale]+$route), 'title' => implode('/', $titles), - 'translated' => $this->translator->trans($this->config['languages'][$locale], [], null, $locale) + 'translated' => $this->translator->trans($this->config['default']['languages'][$locale], [], null, $locale) ]; } } @@ -272,19 +277,9 @@ abstract class AbstractController extends BaseAbstractController implements Serv $response ??= new Response(); //With empty head locale - if (empty($parameters['head']['locale'])) { + if (empty($parameters['locale'])) { //Set head locale - $parameters['head']['locale'] = $this->locale; - } - - //With empty head title and section - if (empty($parameters['head']['title']) && !empty($parameters['section'])) { - //Set head title - $parameters['head']['title'] = implode(' - ', [$parameters['title'], $parameters['section'], $parameters['head']['site']]); - //With empty head title - } elseif (empty($parameters['head']['title'])) { - //Set head title - $parameters['head']['title'] = implode(' - ', [$parameters['title'], $parameters['head']['site']]); + $parameters['locale'] = $this->locale; } //Call twig render method