EventListener/ThemeRequestListener.php
public function onKernelRequest(GetResponseEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
            $value = $this->settingsRouter->get('theme', null);

            /**
             * Throw exception if no theme set by default.
             * This can occur only for routes inside the `main` slot.
             * In that case, exception will not be throw in the admin area.
             */
            if (null === $value && $this->builder->hasRoute($event->getRequest()->get('_route'))) {
                throw new NoActiveThemeException('You must enable a theme to be set has an active theme.');
            }

            if ((null !== $theme = $this->kernel->getThemes()[$value] ?? null) &&
                $this->translator instanceof DataCollectorTranslator) {

                $finder = (new Finder())->files();
                // Parent need to be loaded first
                if (null !== $theme->getParent() &&
                    is_dir($parentTransPath = $theme->getParent()->getPath() . '/translations')) {
                    $finder->in($parentTransPath);
                }
                // Child (current) theme, will override translations
                if (is_dir($transPath = $theme->getPath() . '/translations')) {
                    $finder->in($transPath);
                }

                try {
                    /** @var SplFileInfo $file */
                    foreach ($finder as $file) {
                        [$domain, $locale] = explode('.', $file->getBasename(), 3);
                        switch ($file->getExtension()) {
                            case 'php':
                                $this->translator->addResource('php', (string)$file, $locale, $domain);
                                break;
                            case 'xlf':
                            case 'xliff':
                                $this->translator->addResource('xlf', (string)$file, $locale, $domain);
                                break;
                            case 'yaml':
                                $this->translator->addResource('yaml', (string)$file, $locale, $domain);
                                break;
                        }
                    }
                }
                catch (LogicException $e) {
                }
            }
        }
    }
public function onKernelRequest(GetResponseEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
            $value = $this->settingsRouter->get('theme', null);

            /**
             * Throw exception if no theme set by default.
             * This can occur only for routes inside the `main` slot.
             * In that case, exception will not be throw in the admin area.
             */
            if (null === $value && $this->builder->hasRoute($event->getRequest()->get('_route'))) {
                throw new NoActiveThemeException('You must enable a theme to be set has an active theme.');
            }

            if ((null !== $theme = $this->kernel->getThemes()[$value] ?? null) &&
                $this->translator instanceof DataCollectorTranslator) {

                $finder = (new Finder())->files();
                // Parent need to be loaded first
                if (null !== $theme->getParent() &&
                    is_dir($parentTransPath = $theme->getParent()->getPath() . '/translations')) {
                    $finder->in($parentTransPath);
                }
                // Child (current) theme, will override translations
                if (is_dir($transPath = $theme->getPath() . '/translations')) {
                    $finder->in($transPath);
                }

                try {
                    /** @var SplFileInfo $file */
                    foreach ($finder as $file) {
                        [$domain, $locale] = explode('.', $file->getBasename(), 3);
                        switch ($file->getExtension()) {
                            case 'php':
                                $this->translator->addResource('php', (string)$file, $locale, $domain);
                                break;
                            case 'xlf':
                            case 'xliff':
                                $this->translator->addResource('xlf', (string)$file, $locale, $domain);
                                break;
                            case 'yaml':
                                $this->translator->addResource('yaml', (string)$file, $locale, $domain);
                                break;
                        }
                    }
                }
                catch (LogicException $e) {
                }
            }
        }
    }
@param GetResponseEvent $event

@throws ReflectionException
@throws Exception