File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
lib/internal/Magento/Framework/EntityManager Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -106,4 +106,15 @@ public function getHydrator($entityType)
106
106
$ objectManager = \Magento \Framework \App \ObjectManager::getInstance ();
107
107
return $ objectManager ->get (HydratorPool::class)->getHydrator ($ entityType );
108
108
}
109
+
110
+ /**
111
+ * Check if entity type configuration was set to metadata
112
+ *
113
+ * @param string $entityType
114
+ * @return bool
115
+ */
116
+ public function hasConfiguration ($ entityType )
117
+ {
118
+ return isset ($ this ->metadata [$ entityType ]);
119
+ }
109
120
}
Original file line number Diff line number Diff line change 10
10
*/
11
11
class TypeResolver
12
12
{
13
+ /**
14
+ * @var MetadataPool
15
+ */
16
+ private $ metadataPool ;
17
+
13
18
/**
14
19
* @var array
15
20
*/
@@ -18,6 +23,15 @@ class TypeResolver
18
23
\Magento \SalesRule \Model \Rule \Interceptor::class => \Magento \SalesRule \Api \Data \RuleInterface::class
19
24
];
20
25
26
+ /**
27
+ * TypeResolver constructor.
28
+ * @param MetadataPool $metadataPool
29
+ */
30
+ public function __construct (MetadataPool $ metadataPool )
31
+ {
32
+ $ this ->metadataPool = $ metadataPool ;
33
+ }
34
+
21
35
/**
22
36
* @param object $type
23
37
* @return string
@@ -45,6 +59,12 @@ public function resolve($type)
45
59
throw new \Exception ('Unable to determine data interface for ' . $ className );
46
60
}
47
61
48
- return reset ($ dataInterfaces );
62
+ foreach ($ dataInterfaces as $ dataInterface ) {
63
+ if ($ this ->metadataPool ->hasConfiguration ($ dataInterface )) {
64
+ $ this ->typeMapping [$ className ] = $ dataInterface ;
65
+ }
66
+ }
67
+
68
+ return $ this ->typeMapping [$ className ];
49
69
}
50
70
}
You can’t perform that action at this time.
0 commit comments