/** * Get 'physical' theme * * @return \Magento\Framework\View\Design\ThemeInterface */ public function getPhysicalTheme() { /** @var $parentTheme \Magento\Framework\View\Design\ThemeInterface */ $parentTheme = $this->_theme->getParentTheme(); while ($parentTheme && !$parentTheme->isPhysical()) { $parentTheme = $parentTheme->getParentTheme(); } if (!$parentTheme || !$parentTheme->getId()) { return null; } return $parentTheme; }
/** * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\Event\ManagerInterface $eventDispatcher * @param \Magento\Framework\View\ConfigInterface $viewConfig * @param \Magento\DesignEditor\Model\Config\Control\AbstractControl $configuration * @param \Magento\Framework\View\Design\ThemeInterface $theme * @param \Magento\Framework\View\Design\ThemeInterface $parentTheme */ public function __construct(\Magento\Framework\View\DesignInterface $design, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Event\ManagerInterface $eventDispatcher, \Magento\Framework\View\ConfigInterface $viewConfig, \Magento\DesignEditor\Model\Config\Control\AbstractControl $configuration = null, \Magento\Framework\View\Design\ThemeInterface $theme = null, \Magento\Framework\View\Design\ThemeInterface $parentTheme = null) { $this->_configuration = $configuration; $this->_theme = $theme; $this->_parentTheme = $parentTheme ?: $theme->getParentTheme(); $this->_design = $design; $this->_filesystem = $filesystem; $this->_eventDispatcher = $eventDispatcher; $this->_viewConfigLoader = $viewConfig; $this->_initViewConfigs()->_loadControlsData(); }
/** * Copy changes from 'staging' theme * * @return \Magento\Framework\View\Design\Theme\Domain\StagingInterface */ public function updateFromStagingTheme() { $this->_themeCopyService->copy($this->_theme, $this->_theme->getParentTheme()); return $this; }
/** * Recursively add parent theme configs * * @param ThemeInterface $theme * @param array $iterator * @param int $index * @return array */ private function getParentConfigs(ThemeInterface $theme, array $iterator, $index = 0) { if ($theme->getParentTheme() && $theme->isPhysical()) { $parentDesignPath = $this->resolver->resolve(RulePool::TYPE_FILE, 'etc/view.xml', $this->area, $theme->getParentTheme()); $parentDom = new \DOMDocument(); $parentDom->load($parentDesignPath); $iterator[$index] = $parentDom->saveXML(); $iterator = $this->getParentConfigs($theme->getParentTheme(), $iterator, ++$index); } return $iterator; }
/** * Reset parent themes by type * * @param ThemeInterface $theme * @return int|null */ protected function _getResetParentId(ThemeInterface $theme) { $parentTheme = $theme->getParentTheme(); while ($parentTheme) { foreach ($this->_allowedRelations as $typesSequence) { list($parentType, $childType) = $typesSequence; if ($theme->getType() == $childType && $parentTheme->getType() == $parentType) { return $parentTheme->getId(); } } $parentTheme = $parentTheme->getParentTheme(); } return null; }