Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 3.3 translator arguments changed index #16

Closed
linaori opened this issue Apr 18, 2017 · 0 comments · Fixed by #17
Closed

Symfony 3.3 translator arguments changed index #16

linaori opened this issue Apr 18, 2017 · 0 comments · Fixed by #17

Comments

@linaori
Copy link
Contributor

linaori commented Apr 18, 2017

The translator service in symfony 3.3 has changed arguments. Wrote this little patch that fixes it, but it didn't pass tests. Should probably applied and fixed before 3.3 is released.

diff --git a/src/DependencyInjection/EnumTranslationCompilerPass.php b/src/DependencyInjection/EnumTranslationCompil
index 5f4f79d..a1289d5 100644
--- a/src/DependencyInjection/EnumTranslationCompilerPass.php
+++ b/src/DependencyInjection/EnumTranslationCompilerPass.php
@@ -15,7 +15,21 @@ class EnumTranslationCompilerPass implements CompilerPassInterface
      */
     public function process(ContainerBuilder $container)
     {
-        foreach ($container->getDefinition('translator.default')->getArgument(3)['resource_files'] as $files) {
+        $resource_files = null;
+
+        foreach ($container->getDefinition('translator.default')->getArguments() as $argument) {
+            if (!isset($argument['resource_files'])) {
+                continue;
+            }
+
+            $resource_files = (array) $argument['resource_files'];
+        }
+
+        if (null === $resource_files) {
+            throw new \LogicException('Expected a translator argument to have an array with "resource_files".');
+        }
+
+        foreach ($resource_files as $files) {
             $this->registerEnums($container, array_filter($files, function ($file) {
                 return preg_match('~/enum\.[a-z]+\.[a-z]+$~', $file) === 1;
             }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant