Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DimensionModeConfiguration.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
8 
12 
14 {
18  const DIMENSION_NONE = 'none';
19  const DIMENSION_WEBSITE = 'website';
20  const DIMENSION_CUSTOMER_GROUP = 'customer_group';
21  const DIMENSION_WEBSITE_AND_CUSTOMER_GROUP = 'website_and_customer_group';
29  private $modesMapping = [
30  self::DIMENSION_NONE => [
31  ],
32  self::DIMENSION_WEBSITE => [
33  WebsiteDimensionProvider::DIMENSION_NAME
34  ],
35  self::DIMENSION_CUSTOMER_GROUP => [
36  CustomerGroupDimensionProvider::DIMENSION_NAME
37  ],
38  self::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP => [
39  WebsiteDimensionProvider::DIMENSION_NAME,
40  CustomerGroupDimensionProvider::DIMENSION_NAME
41  ],
42  ];
43 
47  private $scopeConfig;
48 
52  private $currentMode;
53 
57  public function __construct(ScopeConfigInterface $scopeConfig)
58  {
59  $this->scopeConfig = $scopeConfig;
60  }
61 
67  public function getDimensionModes(): array
68  {
69  return $this->modesMapping;
70  }
71 
80  public function getDimensionConfiguration(string $mode = null): array
81  {
82  if ($mode && !isset($this->modesMapping[$mode])) {
83  throw new \InvalidArgumentException(
84  sprintf('Undefined dimension mode "%s".', $mode)
85  );
86  }
87  return $this->modesMapping[$mode ?? $this->getCurrentMode()];
88  }
89 
93  private function getCurrentMode(): string
94  {
95  if (null === $this->currentMode) {
96  $this->currentMode = $this->scopeConfig->getValue(ModeSwitcherConfiguration::XML_PATH_PRICE_DIMENSIONS_MODE)
98  }
99 
100  return $this->currentMode;
101  }
102 }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15