Skip to content

Commit 40c2a9c

Browse files
committed
Fix tests not passing
1 parent 2085a04 commit 40c2a9c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

app/code/Magento/Catalog/Model/Design.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Model;
77

88
use \Magento\Framework\TranslateInterface;
9+
use \Magento\Framework\View\Design\ThemeInterfaceFactory;
910

1011
/**
1112
* Catalog Custom Category design Model
@@ -34,9 +35,9 @@ class Design extends \Magento\Framework\Model\AbstractModel
3435
protected $_localeDate;
3536

3637
/**
37-
* @var \Magento\Framework\View\Design\ThemeInterfaceFactory
38+
* @var ThemeInterfaceFactory
3839
*/
39-
protected $_themeFactory;
40+
private $themeFactory;
4041

4142
/**
4243
* @var TranslateInterface
@@ -48,9 +49,9 @@ class Design extends \Magento\Framework\Model\AbstractModel
4849
* @param \Magento\Framework\Registry $registry
4950
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
5051
* @param \Magento\Framework\View\DesignInterface $design
51-
* @param \Magento\Framework\View\Design\ThemeInterfaceFactory $themeFactory
5252
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
5353
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
54+
* @param ThemeInterfaceFactory $themeFactory
5455
* @param TranslateInterface $translator
5556
* @param array $data
5657
*/
@@ -59,15 +60,16 @@ public function __construct(
5960
\Magento\Framework\Registry $registry,
6061
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
6162
\Magento\Framework\View\DesignInterface $design,
62-
\Magento\Framework\View\Design\ThemeInterfaceFactory $themeFactory,
6363
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
6464
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
6565
array $data = [],
66+
ThemeInterfaceFactory $themeFactory = null,
6667
TranslateInterface $translator = null
6768
) {
6869
$this->_localeDate = $localeDate;
6970
$this->_design = $design;
70-
$this->_themeFactory = $themeFactory;
71+
$this->themeFactory = $themeFactory ?:
72+
\Magento\Framework\App\ObjectManager::getInstance()->get(ThemeInterfaceFactory::class);
7173
$this->translator = $translator ?:
7274
\Magento\Framework\App\ObjectManager::getInstance()->get(TranslateInterface::class);
7375

@@ -77,7 +79,7 @@ public function __construct(
7779
/**
7880
* Apply custom design
7981
*
80-
* @param string $design
82+
* @param \Magento\Framework\View\Design\ThemeInterface|string $design
8183
* @return $this
8284
*/
8385
public function applyCustomDesign($design)
@@ -90,12 +92,13 @@ public function applyCustomDesign($design)
9092
/**
9193
* Apply custom design translations
9294
*
93-
* @param string $design
95+
* @param \Magento\Framework\View\Design\ThemeInterface|string $design
9496
* @return $this
9597
*/
9698
private function applyCustomDesingTranslations($design)
9799
{
98-
$theme = $this->_themeFactory->create()->load($design)->getThemePath();
100+
$design = (is_string($design)) ? $design : $design->getId();
101+
$theme = $this->themeFactory->create()->load($design)->getThemePath();
99102
$this->translator->setTheme($theme)->loadData(null, true);
100103
return $this;
101104
}

0 commit comments

Comments
 (0)