/** * {@inheritdoc} */ public function getThemeCustomizations($area = \Magento\Framework\App\Area::AREA_FRONTEND, $type = \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL) { /** @var $themeCollection \Magento\Theme\Model\ResourceModel\Theme\Collection */ $themeCollection = $this->collectionFactory->create(); $themeCollection->addAreaFilter($area)->addTypeFilter($type); return $themeCollection; }
/** * Assign Theme * * @return void */ protected function assignTheme() { $themes = $this->collectionFactory->create()->loadRegisteredThemes(); /** @var \Magento\Theme\Model\Theme $theme */ foreach ($themes as $theme) { if ($theme->getCode() == 'Magento/luma') { $this->config->assignToStore($theme, [Store::DEFAULT_STORE_ID], ScopeConfigInterface::SCOPE_TYPE_DEFAULT); } } }
public function testGetByAreaWithOtherAreaAndNumericThemeId() { $this->designMock->expects($this->once())->method('getDesignTheme')->will($this->returnValue($this->themeMock)); $this->designMock->expects($this->once())->method('getArea')->will($this->returnValue('design_area')); $this->designMock->expects($this->once())->method('getConfigurationDesignTheme')->will($this->returnValue(12)); $this->themeMock->expects($this->once())->method('getArea')->will($this->returnValue('theme_area')); $this->themeCollectionFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->themeCollectionMock)); $this->themeCollectionMock->expects($this->once())->method('getItemById')->with(12)->will($this->returnValue($this->themeMock)); $this->appStateMock->expects($this->once())->method('getAreaCode')->will($this->returnValue('other_area')); $this->assertEquals($this->themeMock, $this->model->get()); }
/** * Retrieve instance of a theme currently used in an area * * @return \Magento\Framework\View\Design\ThemeInterface */ public function get() { $area = $this->appState->getAreaCode(); if ($this->design->getDesignTheme()->getArea() == $area || $this->design->getArea() == $area) { return $this->design->getDesignTheme(); } /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themeCollection */ $themeCollection = $this->themeFactory->create(); $themeIdentifier = $this->design->getConfigurationDesignTheme($area); if (is_numeric($themeIdentifier)) { $result = $themeCollection->getItemById($themeIdentifier); } else { $themeFullPath = $area . \Magento\Framework\View\Design\ThemeInterface::PATH_SEPARATOR . $themeIdentifier; $result = $themeCollection->getThemeByFullPath($themeFullPath); } return $result; }
/** * {@inheritdoc} */ public function install(array $fixtures) { $pageGroupConfig = ['pages' => ['block' => '', 'for' => 'all', 'layout_handle' => 'default', 'template' => 'widget/static_block/default.phtml', 'page_id' => ''], 'all_pages' => ['block' => '', 'for' => 'all', 'layout_handle' => 'default', 'template' => 'widget/static_block/default.phtml', 'page_id' => ''], 'anchor_categories' => ['entities' => '', 'block' => '', 'for' => 'all', 'is_anchor_only' => 0, 'layout_handle' => 'catalog_category_view_type_layered', 'template' => 'widget/static_block/default.phtml', 'page_id' => '']]; foreach ($fixtures as $fileName) { $fileName = $this->fixtureManager->getFixture($fileName); if (!file_exists($fileName)) { continue; } $rows = $this->csvReader->getData($fileName); $header = array_shift($rows); foreach ($rows as $row) { $data = []; foreach ($row as $key => $value) { $data[$header[$key]] = $value; } $row = $data; /** @var \Magento\Widget\Model\ResourceModel\Widget\Instance\Collection $instanceCollection */ $instanceCollection = $this->appCollectionFactory->create(); $instanceCollection->addFilter('title', $row['title']); if ($instanceCollection->count() > 0) { continue; } /** @var \Magento\Cms\Model\Block $block */ $block = $this->cmsBlockFactory->create()->load($row['block_identifier'], 'identifier'); if (!$block) { continue; } $widgetInstance = $this->widgetFactory->create(); $code = $row['type_code']; $themeId = $this->themeCollectionFactory->create()->getThemeByFullPath($row['theme_path'])->getId(); $type = $widgetInstance->getWidgetReference('code', $code, 'type'); $pageGroup = []; $group = $row['page_group']; $pageGroup['page_group'] = $group; $pageGroup[$group] = array_merge($pageGroupConfig[$group], unserialize($row['group_data'])); if (!empty($pageGroup[$group]['entities'])) { $pageGroup[$group]['entities'] = $this->getCategoryByUrlKey($pageGroup[$group]['entities'])->getId(); } $widgetInstance->setType($type)->setCode($code)->setThemeId($themeId); $widgetInstance->setTitle($row['title'])->setStoreIds([\Magento\Store\Model\Store::DEFAULT_STORE_ID])->setWidgetParameters(['block_id' => $block->getId()])->setPageGroups([$pageGroup]); $widgetInstance->save(); } } }
/** * Retrieve theme instance by its identifier * * @param int $themeId * @return \Magento\Theme\Model\Theme|null */ protected function _getThemeInstance($themeId) { /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themeCollection */ $themeCollection = $this->_themesFactory->create(); return $themeCollection->getItemById($themeId); }
/** * @return \Magento\Theme\Model\ResourceModel\Theme\Collection */ public function createThemeResource() { return $this->themeResourceFactory->create(); }