diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7c2e89d0..e03fe2c0 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,9 +17,16 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $builder = new TreeBuilder(); + $treeBuilder = new TreeBuilder('bazinga_js_translation'); - $builder->root('bazinga_js_translation') + if (method_exists($treeBuilder, 'getRootNode')) { + $rootNode = $treeBuilder->getRootNode(); + } else { + // BC layer for symfony/config 4.1 and older + $rootNode = $treeBuilder->root('bazinga_js_translation'); + } + + $rootNode ->fixXmlConfig('active_locale') ->fixXmlConfig('active_domain') ->children() @@ -36,6 +43,6 @@ public function getConfigTreeBuilder() ->end() ->end(); - return $builder; + return $treeBuilder; } } diff --git a/Tests/Fixtures/app/AppKernel.php b/Tests/Fixtures/app/AppKernel.php index 6904d4f8..e720410b 100644 --- a/Tests/Fixtures/app/AppKernel.php +++ b/Tests/Fixtures/app/AppKernel.php @@ -49,6 +49,11 @@ public function getRootDir() return __DIR__; } + public function getProjectDir() + { + return __DIR__.'/../'; + } + public function getCacheDir() { return sys_get_temp_dir().'/'.Kernel::VERSION.'/bazinga-js-translation/cache/'.$this->environment; @@ -70,6 +75,10 @@ public function registerContainerConfiguration(LoaderInterface $loader) if (self::VERSION_ID > 30200) { $loader->load(__DIR__.'/config/disable_annotations.yml'); } + + if (self::VERSION_ID < 40200 && file_exists(__DIR__.'/Resources/translations') === false) { + self::recurseCopy(__DIR__.'/../translations', __DIR__.'/Resources/translations'); + } } public function serialize() @@ -81,4 +90,21 @@ public function unserialize($str) { call_user_func_array(array($this, '__construct'), unserialize($str)); } + + private static function recurseCopy($src, $dst) + { + $dir = opendir($src); + @mkdir($dst, 0777, true); + while (false !== ($file = readdir($dir))) { + if (($file !== '.') && ($file !== '..')) { + if (is_dir($src.'/'.$file)) { + self::recurseCopy($src.'/'.$file, $dst.'/'.$file); + } else { + copy($src.'/'.$file, $dst.'/'.$file); + } + } + } + + closedir($dir); + } } diff --git a/Tests/Fixtures/app/Resources/translations/foo.en.yml b/Tests/Fixtures/translations/foo.en.yml similarity index 100% rename from Tests/Fixtures/app/Resources/translations/foo.en.yml rename to Tests/Fixtures/translations/foo.en.yml diff --git a/Tests/Fixtures/app/Resources/translations/front.en.yml b/Tests/Fixtures/translations/front.en.yml similarity index 100% rename from Tests/Fixtures/app/Resources/translations/front.en.yml rename to Tests/Fixtures/translations/front.en.yml diff --git a/Tests/Fixtures/app/Resources/translations/front.fr.yml b/Tests/Fixtures/translations/front.fr.yml similarity index 100% rename from Tests/Fixtures/app/Resources/translations/front.fr.yml rename to Tests/Fixtures/translations/front.fr.yml diff --git a/Tests/Fixtures/app/Resources/translations/messages.ach_UG.yml b/Tests/Fixtures/translations/messages.ach_UG.yml similarity index 100% rename from Tests/Fixtures/app/Resources/translations/messages.ach_UG.yml rename to Tests/Fixtures/translations/messages.ach_UG.yml diff --git a/Tests/Fixtures/app/Resources/translations/messages.en.yml b/Tests/Fixtures/translations/messages.en.yml similarity index 100% rename from Tests/Fixtures/app/Resources/translations/messages.en.yml rename to Tests/Fixtures/translations/messages.en.yml diff --git a/Tests/Fixtures/app/Resources/translations/messages.es.yml b/Tests/Fixtures/translations/messages.es.yml similarity index 100% rename from Tests/Fixtures/app/Resources/translations/messages.es.yml rename to Tests/Fixtures/translations/messages.es.yml diff --git a/Tests/Fixtures/app/Resources/translations/messages.fr.yml b/Tests/Fixtures/translations/messages.fr.yml similarity index 100% rename from Tests/Fixtures/app/Resources/translations/messages.fr.yml rename to Tests/Fixtures/translations/messages.fr.yml diff --git a/Tests/Fixtures/app/Resources/translations/numerics.en.xliff b/Tests/Fixtures/translations/numerics.en.xliff similarity index 100% rename from Tests/Fixtures/app/Resources/translations/numerics.en.xliff rename to Tests/Fixtures/translations/numerics.en.xliff diff --git a/Tests/Fixtures/app/Resources/translations/numerics.fr.xliff b/Tests/Fixtures/translations/numerics.fr.xliff similarity index 100% rename from Tests/Fixtures/app/Resources/translations/numerics.fr.xliff rename to Tests/Fixtures/translations/numerics.fr.xliff