Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DesignTheme.php
Go to the documentation of this file.
1 <?php
7 
12 
20 {
24  private $arrayManager;
25 
29  private $themeList;
30 
35  public function __construct(
36  ArrayManager $arrayManager,
37  ListInterface $themeList
38  ) {
39  $this->arrayManager = $arrayManager;
40  $this->themeList = $themeList;
41  }
42 
50  public function process(array $config)
51  {
52  foreach ($config as $scope => &$item) {
53  if ($scope === \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
54  $item = $this->changeThemeFullPathToIdentifier($item);
55  } else {
56  foreach ($item as &$scopeItems) {
57  $scopeItems = $this->changeThemeFullPathToIdentifier($scopeItems);
58  }
59  }
60  }
61 
62  return $config;
63  }
64 
72  private function changeThemeFullPathToIdentifier($configItems)
73  {
74  $theme = null;
75  $themeIdentifier = $this->arrayManager->get(DesignInterface::XML_PATH_THEME_ID, $configItems);
76  if (!empty($themeIdentifier)) {
77  if (!is_numeric($themeIdentifier)) {
78  // workaround for case when db is not available
79  try {
80  $theme = $this->themeList->getThemeByFullPath($themeIdentifier);
81  } catch (\DomainException $domainException) {
82  $theme = null;
83  }
84  }
85 
86  if ($theme && $theme->getId()) {
87  return $this->arrayManager->set(DesignInterface::XML_PATH_THEME_ID, $configItems, $theme->getId());
88  }
89  }
90 
91  return $configItems;
92  }
93 }
$config
Definition: fraud_order.php:17
__construct(ArrayManager $arrayManager, ListInterface $themeList)
Definition: DesignTheme.php:35
$themeList
Definition: config_data.php:15
$theme