@@ -24,11 +24,11 @@ class FieldMapperResolver implements FieldMapperInterface
24
24
private $ fieldMappers ;
25
25
26
26
/**
27
- * Field Mapper instance
27
+ * Field Mapper instance per entity
28
28
*
29
- * @var FieldMapperInterface
29
+ * @var FieldMapperInterface[]
30
30
*/
31
- private $ fieldMapperEntity ;
31
+ private $ fieldMapperEntity = [] ;
32
32
33
33
/**
34
34
* @param ObjectManagerInterface $objectManager
@@ -69,7 +69,7 @@ public function getAllAttributesTypes($context = [])
69
69
*/
70
70
private function getEntity ($ entityType )
71
71
{
72
- if (empty ($ this ->fieldMapperEntity )) {
72
+ if (empty ($ this ->fieldMapperEntity [ $ entityType ] )) {
73
73
if (empty ($ entityType )) {
74
74
throw new \Exception (
75
75
'No entity type given '
@@ -81,13 +81,13 @@ private function getEntity($entityType)
81
81
);
82
82
}
83
83
$ fieldMapperClass = $ this ->fieldMappers [$ entityType ];
84
- $ this ->fieldMapperEntity = $ this ->objectManager ->create ($ fieldMapperClass );
85
- if (!($ this ->fieldMapperEntity instanceof FieldMapperInterface)) {
84
+ $ this ->fieldMapperEntity [ $ entityType ] = $ this ->objectManager ->create ($ fieldMapperClass );
85
+ if (!($ this ->fieldMapperEntity [ $ entityType ] instanceof FieldMapperInterface)) {
86
86
throw new \InvalidArgumentException (
87
87
'Field mapper must implement \Magento\Elasticsearch\Model\Adapter\FieldMapperInterface '
88
88
);
89
89
}
90
90
}
91
- return $ this ->fieldMapperEntity ;
91
+ return $ this ->fieldMapperEntity [ $ entityType ] ;
92
92
}
93
93
}
0 commit comments