Skip to content

Commit 1d3c741

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-52105' into MAGETWO-52835
2 parents 8a1f653 + 2835452 commit 1d3c741

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/internal/Magento/Framework/EntityManager/MetadataPool.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,15 @@ public function getHydrator($entityType)
106106
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
107107
return $objectManager->get(HydratorPool::class)->getHydrator($entityType);
108108
}
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+
}
109120
}

lib/internal/Magento/Framework/EntityManager/TypeResolver.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
*/
1111
class TypeResolver
1212
{
13+
/**
14+
* @var MetadataPool
15+
*/
16+
private $metadataPool;
17+
1318
/**
1419
* @var array
1520
*/
@@ -18,6 +23,15 @@ class TypeResolver
1823
\Magento\SalesRule\Model\Rule\Interceptor::class => \Magento\SalesRule\Api\Data\RuleInterface::class
1924
];
2025

26+
/**
27+
* TypeResolver constructor.
28+
* @param MetadataPool $metadataPool
29+
*/
30+
public function __construct(MetadataPool $metadataPool)
31+
{
32+
$this->metadataPool = $metadataPool;
33+
}
34+
2135
/**
2236
* @param object $type
2337
* @return string
@@ -45,6 +59,12 @@ public function resolve($type)
4559
throw new \Exception('Unable to determine data interface for ' . $className);
4660
}
4761

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];
4969
}
5070
}

0 commit comments

Comments
 (0)