Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IndexScopeResolver.php
Go to the documentation of this file.
1 <?php
8 
13 
15 {
19  private $resource;
20 
24  private $scopeResolver;
25 
30  public function __construct(
31  ResourceConnection $resource,
32  ScopeResolverInterface $scopeResolver
33  ) {
34  $this->resource = $resource;
35  $this->scopeResolver = $scopeResolver;
36  }
37 
43  public function resolve($index, array $dimensions)
44  {
45  $tableNameParts = [];
46  foreach ($dimensions as $dimension) {
47  switch ($dimension->getName()) {
48  case 'scope':
49  $tableNameParts[$dimension->getName()] = $dimension->getName() . $this->getScopeId($dimension);
50  break;
51  default:
52  $tableNameParts[$dimension->getName()] = $dimension->getName() . $dimension->getValue();
53  }
54  }
55  ksort($tableNameParts);
56  array_unshift($tableNameParts, $index);
57 
58  return $this->resource->getTableName(implode('_', $tableNameParts));
59  }
60 
67  private function getScopeId($dimension)
68  {
69  $scopeId = $dimension->getValue();
70 
71  if (!is_numeric($scopeId)) {
72  $scopeId = $this->scopeResolver->getScope($scopeId)->getId();
73  }
74 
75  return $scopeId;
76  }
77 }
$resource
Definition: bulk.php:12
__construct(ResourceConnection $resource, ScopeResolverInterface $scopeResolver)
$index
Definition: list.phtml:44