From baf9f5e407aacf8a715bebff3ef61d8610ca0e34 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Tue, 13 Aug 2024 22:59:46 +0200 Subject: [PATCH] =?UTF-8?q?[Translator]=C2=A0Revert=20#1965,=20which=20bre?= =?UTF-8?q?ak=20cache=20warmup=20for=20Symfony=20applications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Translator/doc/index.rst | 4 -- .../TranslatorCompilerPass.php | 40 ------------------- src/Translator/src/UxTranslatorBundle.php | 7 ---- .../tests/Kernel/FrameworkAppKernel.php | 4 -- .../tests/UxTranslatorBundleTest.php | 1 - 5 files changed, 56 deletions(-) delete mode 100644 src/Translator/src/DependencyInjection/TranslatorCompilerPass.php diff --git a/src/Translator/doc/index.rst b/src/Translator/doc/index.rst index 0b36da695ac..9bfd9e32583 100644 --- a/src/Translator/doc/index.rst +++ b/src/Translator/doc/index.rst @@ -71,10 +71,6 @@ For a better developer experience, TypeScript types definitions are also generat Then, you will be able to import those JavaScript translations in your assets. Don't worry about your final bundle size, only the translations you use will be included in your final bundle, thanks to the `tree shaking `_. -.. note:: - - This package requires the `translator` to be enabled in your Symfony application. If you don't use the `translator` service, the warmup command will not generate any translations. - Configuring the dumped translations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/Translator/src/DependencyInjection/TranslatorCompilerPass.php b/src/Translator/src/DependencyInjection/TranslatorCompilerPass.php deleted file mode 100644 index 1b69209aa00..00000000000 --- a/src/Translator/src/DependencyInjection/TranslatorCompilerPass.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\Translator\DependencyInjection; - -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\Translation\TranslatorBagInterface; - -class TranslatorCompilerPass implements CompilerPassInterface -{ - public function process(ContainerBuilder $container): void - { - if (!$this->hasValidTranslator($container)) { - $container->removeDefinition('ux.translator.cache_warmer.translations_cache_warmer'); - } - } - - private function hasValidTranslator(ContainerBuilder $containerBuilder): bool - { - if (!$containerBuilder->hasDefinition('translator')) { - return false; - } - - $translator = $containerBuilder->getDefinition('translator'); - if (!is_subclass_of($translator->getClass(), TranslatorBagInterface::class)) { - return false; - } - - return true; - } -} diff --git a/src/Translator/src/UxTranslatorBundle.php b/src/Translator/src/UxTranslatorBundle.php index ff6c74928aa..91fa829a11b 100644 --- a/src/Translator/src/UxTranslatorBundle.php +++ b/src/Translator/src/UxTranslatorBundle.php @@ -11,9 +11,7 @@ namespace Symfony\UX\Translator; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; -use Symfony\UX\Translator\DependencyInjection\TranslatorCompilerPass; /** * @author Hugo Alliaume @@ -28,9 +26,4 @@ public function getPath(): string { return \dirname(__DIR__); } - - public function build(ContainerBuilder $container): void - { - $container->addCompilerPass(new TranslatorCompilerPass()); - } } diff --git a/src/Translator/tests/Kernel/FrameworkAppKernel.php b/src/Translator/tests/Kernel/FrameworkAppKernel.php index 2686ab7e54d..98c0ca6a703 100644 --- a/src/Translator/tests/Kernel/FrameworkAppKernel.php +++ b/src/Translator/tests/Kernel/FrameworkAppKernel.php @@ -38,10 +38,6 @@ public function registerContainerConfiguration(LoaderInterface $loader) 'secret' => '$ecret', 'test' => true, 'translator' => [ - 'enabled' => match ($this->environment) { - 'test_without_translator' => false, - default => true, - }, 'fallbacks' => ['en'], ], 'http_method_override' => false, diff --git a/src/Translator/tests/UxTranslatorBundleTest.php b/src/Translator/tests/UxTranslatorBundleTest.php index fe17709d8b0..8f244289558 100644 --- a/src/Translator/tests/UxTranslatorBundleTest.php +++ b/src/Translator/tests/UxTranslatorBundleTest.php @@ -22,7 +22,6 @@ public static function provideKernels() { yield 'empty' => [new EmptyAppKernel('test', true)]; yield 'framework' => [new FrameworkAppKernel('test', true)]; - yield 'framework without translator' => [new FrameworkAppKernel('test_without_translator', true)]; } /**