|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / app / code / WeltPixel / Backend / Helper / |
Filename | /home/dev2.destoffenstraat.com/app/code/WeltPixel/Backend/Helper/Utility.php |
Size | 3 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 17-May-2021 07:12 |
Last accessed | 22-Aug-2025 02:07 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace WeltPixel\Backend\Helper;
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
use \Magento\Store\Api\StoreRepositoryInterface;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Utility extends \Magento\Framework\App\Helper\AbstractHelper
{
/** @var ThemeProviderInterface */
protected $themeProvider;
/** @var StoreRepositoryInterface */
protected $storeRepository;
/** @var array */
protected $storeThemesLocales = [];
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param ThemeProviderInterface $themeProvider
* @param StoreRepositoryInterface $storeRepository
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
ThemeProviderInterface $themeProvider,
StoreRepositoryInterface $storeRepository
)
{
parent::__construct($context);
$this->themeProvider = $themeProvider;
$this->storeRepository = $storeRepository;
}
public function isPearlThemeUsed($storeCode = null)
{
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$theme = $this->themeProvider->getThemeById($themeId);
$isPearlTheme = $this->_validatePearlTheme($theme);
return $isPearlTheme;
}
/**
* @param \Magento\Theme\Model\Theme $theme
* @return bool
*/
protected function _validatePearlTheme($theme)
{
$pearlThemePath = 'Pearl/weltpixel';
do {
if ($theme->getThemePath() == $pearlThemePath) {
return true;
}
$theme = $theme->getParentTheme();
} while ($theme);
return false;
}
/**
* @return array
*/
public function getStoreThemesLocales() {
if (count($this->storeThemesLocales)) {
return $this->storeThemesLocales;
}
$stores = $this->storeRepository->getList();
$result = [];
foreach ($stores as $store) {
$storeId = $store["store_id"];
if (!$storeId) continue;
$storeCode = $store["code"];
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$locale = $this->scopeConfig->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$theme = $this->themeProvider->getThemeById($themeId);
$result[$theme->getThemePath().'/'.$locale] = $storeCode;
}
$this->storeThemesLocales = $result;
return $this->storeThemesLocales;
}
}
namespace WeltPixel\Backend\Helper;
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
use \Magento\Store\Api\StoreRepositoryInterface;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Utility extends \Magento\Framework\App\Helper\AbstractHelper
{
/** @var ThemeProviderInterface */
protected $themeProvider;
/** @var StoreRepositoryInterface */
protected $storeRepository;
/** @var array */
protected $storeThemesLocales = [];
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param ThemeProviderInterface $themeProvider
* @param StoreRepositoryInterface $storeRepository
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
ThemeProviderInterface $themeProvider,
StoreRepositoryInterface $storeRepository
)
{
parent::__construct($context);
$this->themeProvider = $themeProvider;
$this->storeRepository = $storeRepository;
}
public function isPearlThemeUsed($storeCode = null)
{
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$theme = $this->themeProvider->getThemeById($themeId);
$isPearlTheme = $this->_validatePearlTheme($theme);
return $isPearlTheme;
}
/**
* @param \Magento\Theme\Model\Theme $theme
* @return bool
*/
protected function _validatePearlTheme($theme)
{
$pearlThemePath = 'Pearl/weltpixel';
do {
if ($theme->getThemePath() == $pearlThemePath) {
return true;
}
$theme = $theme->getParentTheme();
} while ($theme);
return false;
}
/**
* @return array
*/
public function getStoreThemesLocales() {
if (count($this->storeThemesLocales)) {
return $this->storeThemesLocales;
}
$stores = $this->storeRepository->getList();
$result = [];
foreach ($stores as $store) {
$storeId = $store["store_id"];
if (!$storeId) continue;
$storeCode = $store["code"];
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$locale = $this->scopeConfig->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$theme = $this->themeProvider->getThemeById($themeId);
$result[$theme->getThemePath().'/'.$locale] = $storeCode;
}
$this->storeThemesLocales = $result;
return $this->storeThemesLocales;
}
}