+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
+use Symfony\Component\Mailer\MailerInterface;
+use Symfony\Component\Mime\Address;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Routing\RouterInterface;
+use Symfony\Component\Translation\TranslatorInterface;
+use Rapsys\UserBundle\Utils\Slugger;
+use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
+use Symfony\Component\DependencyInjection\ContainerAwareTrait;
+
+
+class DefaultController {
+ use ControllerTrait {
+ //Rename render as _render
+ render as protected _render;
+ }
+
+ ///Config array
+ protected $config;
+
+ ///Context array
+ protected $context;
+
+ ///Router instance
+ protected $router;
+
+ ///Translator instance
+ protected $translator;
+
+ /**
+ * @var ContainerInterface
+ */
+ protected $container;
+
+ /**
+ * Inject container and translator interface
+ *
+ * @param ContainerInterface $container The container instance
+ * @param RouterInterface $router The router instance
+ * @param TranslatorInterface $translator The translator instance
+ */
+ public function __construct(ContainerInterface $container, RouterInterface $router, RequestStack $requestStack, TranslatorInterface $translator) {
+ //Retrieve config
+ $this->config = $container->getParameter($this->getAlias());
+
+ //Set the container
+ $this->container = $container;
+
+ //Set the router
+ $this->router = $router;
+
+ //Set the translator
+ $this->translator = $translator;
+
+ //Set the context
+ $this->context = [
+ 'copy' => [
+ 'by' => $translator->trans($this->config['copy']['by']),
+ 'link' => $this->config['copy']['link'],
+ 'long' => $translator->trans($this->config['copy']['long']),
+ 'short' => $translator->trans($this->config['copy']['short']),
+ 'title' => $this->config['copy']['title']
+ ],
+ 'site' => [
+ 'ico' => $this->config['site']['ico'],
+ 'logo' => $this->config['site']['logo'],
+ 'png' => $this->config['site']['png'],
+ 'svg' => $this->config['site']['svg'],
+ 'title' => $translator->trans($this->config['site']['title']),
+ 'url' => $router->generate($this->config['site']['url']),
+ ],
+ 'canonical' => null,
+ 'alternates' => [],
+ 'forms' => []
+ ];
+
+ //Get current locale
+ #$currentLocale = $router->getContext()->getParameters()['_locale'];
+ $currentLocale = $requestStack->getCurrentRequest()->getLocale();
+
+ //Set translator locale
+ //XXX: allow LocaleSubscriber on the fly locale change for first page
+ $this->translator->setLocale($currentLocale);
+
+ //Iterate on locales excluding current one
+ foreach($this->config['locales'] as $locale) {
+ //Set titles
+ $titles = [];
+
+ //Iterate on other locales
+ foreach(array_diff($this->config['locales'], [$locale]) as $other) {
+ $titles[$other] = $translator->trans($this->config['languages'][$locale], [], null, $other);
+ }