Quellcode durchsuchen

[translatable] support #366 for older versions

gedi vor 13 Jahren
Ursprung
Commit
f6b75628a4

+ 15 - 4
lib/Gedmo/Translatable/Query/TreeWalker/TranslationWalker.php

@@ -231,10 +231,21 @@ class TranslationWalker extends SqlWalker
                     $result .= $this->components[$decl->rangeVariableDeclaration->aliasIdentificationVariable];
                 }
             }
-            foreach ($decl->joins as $join) {
-                if ($join instanceof Join) {
-                    if (isset($this->components[$join->joinAssociationDeclaration->aliasIdentificationVariable])) {
-                        $result .= $this->components[$join->joinAssociationDeclaration->aliasIdentificationVariable];
+            if (isset($decl->joinVariableDeclarations)) {
+                foreach ($decl->joinVariableDeclarations as $joinDecl) {
+                    if ($joinDecl->join instanceof Join) {
+                        if (isset($this->components[$joinDecl->join->aliasIdentificationVariable])) {
+                            $result .= $this->components[$joinDecl->join->aliasIdentificationVariable];
+                        }
+                    }
+                }
+            } else {
+                // based on new changes
+                foreach ($decl->joins as $join) {
+                    if ($join instanceof Join) {
+                        if (isset($this->components[$join->joinAssociationDeclaration->aliasIdentificationVariable])) {
+                            $result .= $this->components[$join->joinAssociationDeclaration->aliasIdentificationVariable];
+                        }
                     }
                 }
             }

+ 3 - 2
tests/Gedmo/Mapping/Driver/Yaml/Mapping.Fixture.Yaml.User.dcm.yml

@@ -25,9 +25,10 @@ Mapping\Fixture\Yaml\User:
     company:
       type: string
       length: 128
+      nullable: true
       gedmo:
-        translatable:
-          fallback: true
+          translatable:
+              fallback: true
   indexes:
     search_idx:
       columns: username