59 $this->_collectionFactory = $collectionFactory;
60 $this->_themeCollection = $filesystemCollection;
68 public function register()
70 $this->_themeCollection->clear();
72 foreach ($this->_themeCollection as
$theme) {
76 $this->checkPhysicalThemes()->checkAllowedThemeRelations();
96 if ($themeModel->getId()) {
101 $tempId =
$theme->getFullPath();
102 if (in_array($tempId, $inheritanceChain)) {
103 throw new LocalizedException(
__(
'Circular-reference in theme inheritance detected for "%1"', $tempId));
105 $inheritanceChain[] = $tempId;
106 $parentTheme =
$theme->getParentTheme();
109 $theme->setParentId($parentTheme->getId());
113 $theme->setType(ThemeInterface::TYPE_PHYSICAL);
127 $themeDirectory =
$theme->getCustomization()->getThemeFilesPath();
128 if (!
$theme->getPreviewImage() || !$themeDirectory) {
131 $imagePath = $themeDirectory .
'/' .
$theme->getPreviewImage();
132 if (0 === strpos($imagePath, $themeDirectory)) {
133 $theme->getThemeImage()->createPreviewImage($imagePath);
146 return $this->_collectionFactory->create()->getThemeByFullPath($fullPath);
154 public function checkPhysicalThemes()
158 foreach ($themes as
$theme) {
159 if (!$this->_themeCollection->hasTheme(
$theme)) {
171 public function checkAllowedThemeRelations()
173 foreach ($this->_forbiddenRelations as $typesSequence) {
174 list($parentType, $childType) = $typesSequence;
176 $collection->addTypeRelationFilter($parentType, $childType);
180 if (
$theme->getParentId() != $parentId) {
181 $theme->setParentId($parentId)->save();
196 $parentTheme =
$theme->getParentTheme();
197 while ($parentTheme) {
198 foreach ($this->_allowedRelations as $typesSequence) {
199 list($parentType, $childType) = $typesSequence;
200 if (
$theme->getType() == $childType && $parentTheme->getType() == $parentType) {
201 return $parentTheme->getId();
204 $parentTheme = $parentTheme->getParentTheme();
_getResetParentId(ThemeInterface $theme)
getThemeFromDb($fullPath)
_registerThemeRecursively(&$theme, $inheritanceChain=[])
__construct(\Magento\Theme\Model\ResourceModel\Theme\Data\CollectionFactory $collectionFactory, \Magento\Theme\Model\Theme\Data\Collection $filesystemCollection)
_savePreviewImage(ThemeInterface $theme)