Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScopeProxy.php
Go to the documentation of this file.
1 <?php
8 
10 
14 class ScopeProxy implements \Magento\Framework\Search\Request\IndexScopeResolverInterface
15 {
21  private $objectManager;
22 
26  private $states = [];
27 
31  private $scopeState;
32 
40  public function __construct(
41  \Magento\Framework\ObjectManagerInterface $objectManager,
42  State $scopeState,
43  array $states
44  ) {
45  $this->objectManager = $objectManager;
46  $this->scopeState = $scopeState;
47  $this->states = $states;
48  }
49 
57  private function create($state)
58  {
59  if (!array_key_exists($state, $this->states)) {
60  throw new UnknownStateException(__("Requested resolver for unknown indexer state: $state"));
61  }
62  return $this->objectManager->create($this->states[$state]);
63  }
64 
68  public function resolve($index, array $dimensions)
69  {
70  return $this->create($this->scopeState->getState())->resolve($index, $dimensions);
71  }
72 }
$objectManager
Definition: bootstrap.php:17
__()
Definition: __.php:13
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, State $scopeState, array $states)
Definition: ScopeProxy.php:40
$index
Definition: list.phtml:44