Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScopeResolver.php
Go to the documentation of this file.
1 <?php
8 
13 
18 {
22  private $objectManager;
23 
27  private $metadataPool;
28 
34  public function __construct(
35  ObjectManagerInterface $objectManager,
36  MetadataPool $metadataPool
37  ) {
38  $this->objectManager = $objectManager;
39  $this->metadataPool = $metadataPool;
40  }
41 
49  public function getEntityContext($entityType, $entityData = [])
50  {
51  $entityContext = [];
52  $metadata = $this->metadataPool->getMetadata($entityType);
53  foreach ($metadata->getEntityContext() as $contextProviderClass) {
54  $contextProvider = $this->objectManager->get($contextProviderClass);
55  if (!$contextProvider instanceof ScopeProviderInterface) {
57  new Phrase(
58  'The configuration for the "%1" type is incorrect. '
59  . 'Verify the type and configuration and try again.',
60  [$entityType]
61  )
62  );
63  }
64  $entityContext[] = $contextProvider->getContext($entityType, $entityData);
65  }
66  return $entityContext;
67  }
68 }
getEntityContext($entityType, $entityData=[])
__construct(ObjectManagerInterface $objectManager, MetadataPool $metadataPool)
$objectManager
Definition: bootstrap.php:17