Пример #1
0
 /**
  * Cached video config
  *
  * @return $this
  */
 protected function initConfig()
 {
     if ($this->cachedVideoConfig === null) {
         $this->cachedVideoConfig = $this->viewConfig->getViewConfig(['area' => Area::AREA_FRONTEND, 'themeModel' => $this->currentTheme]);
     }
     return $this;
 }
Пример #2
0
 /**
  * @param FallbackContext $assetContext
  * @return \Magento\Framework\Config\View
  */
 public function getConfig(FallbackContext $assetContext)
 {
     $themePath = $assetContext->getAreaCode() . '/' . $assetContext->getThemePath();
     if (!isset($this->config[$themePath])) {
         $this->config[$themePath] = $this->viewConfig->getViewConfig(['area' => $assetContext->getAreaCode(), 'themeModel' => $this->getThemeProvider()->getThemeByFullPath($themePath)]);
     }
     return $this->config[$themePath];
 }
Пример #3
0
 /**
  * Retrieve view configuration data
  *
  * Collect data for 'Magento_Catalog' module from /etc/view.xml files.
  *
  * @return array
  */
 protected function getData()
 {
     if (!$this->data) {
         foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
             $config = $this->viewConfig->getViewConfig(['area' => Area::AREA_FRONTEND, 'themeModel' => $theme]);
             $this->data = array_merge($this->data, $this->applyFilters($config->getVars('Magento_Catalog')));
         }
     }
     return $this->data;
 }
Пример #4
0
 /**
  * Retrieve view configuration data
  *
  * Collect data for 'Magento_Catalog' module from /etc/view.xml files.
  *
  * @return array
  */
 protected function getData()
 {
     if (!$this->data) {
         /** @var \Magento\Theme\Model\Theme $theme */
         foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
             $config = $this->viewConfig->getViewConfig(['area' => Area::AREA_FRONTEND, 'themeModel' => $theme]);
             $images = $config->getMediaEntities('Magento_Catalog', ImageHelper::MEDIA_TYPE_CONFIG_NODE);
             foreach ($images as $imageId => $imageData) {
                 $this->data[$theme->getCode() . $imageId] = array_merge(['id' => $imageId], $imageData);
             }
         }
     }
     return $this->data;
 }
Пример #5
0
 /**
  * Get view config object
  *
  * @return \Magento\Framework\Config\View
  */
 protected function _getConfigView()
 {
     if (null === $this->_configView) {
         $this->_configView = $this->_viewConfig->getViewConfig();
     }
     return $this->_configView;
 }
Пример #6
0
 /**
  * Merged config from view.xml
  *
  * @return array
  */
 public function getImageConfig()
 {
     $imageConfig = [];
     foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
         $config = $this->viewConfig->getViewConfig(['area' => Area::AREA_FRONTEND, 'themeModel' => $theme]);
         $imageConfig = array_merge($imageConfig, $config->getMediaEntities('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE));
     }
     return $imageConfig;
 }
Пример #7
0
 /**
  * @magentoAppIsolation enabled
  */
 public function testGetConfigCustomized()
 {
     $this->_emulateFixtureTheme();
     /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
     $theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface')->getDesignTheme();
     $customConfigFile = $theme->getCustomization()->getCustomViewConfigPath();
     /** @var $filesystem \Magento\Framework\Filesystem */
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem');
     $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $relativePath = $directory->getRelativePath($customConfigFile);
     try {
         $directory->writeFile($relativePath, '<?xml version="1.0" encoding="UTF-8"?>
             <view><vars  module="Namespace_Module"><var name="customVar">custom value</var></vars></view>');
         $config = $this->_viewConfig->getViewConfig();
         $this->assertInstanceOf('Magento\\Framework\\Config\\View', $config);
         $this->assertEquals(['customVar' => 'custom value'], $config->getVars('Namespace_Module'));
     } catch (\Exception $e) {
         $directory->delete($relativePath);
         throw $e;
     }
     $directory->delete($relativePath);
 }
Пример #8
0
 /**
  * Get variable value from view configuration
  *
  * Module name can be omitted. If omitted, it will be determined automatically.
  *
  * @param string $name variable name
  * @param string|null $module optional module name
  * @return string|false
  */
 public function getVar($name, $module = null)
 {
     $module = $module ?: $this->getModuleName();
     return $this->_viewConfig->getViewConfig()->getVarValue($module, $name);
 }
Пример #9
0
 /**
  * @param FallbackContext $assetContext
  * @return \Magento\Framework\Config\View
  */
 public function getConfig(FallbackContext $assetContext)
 {
     return $this->viewConfig->getViewConfig(['area' => $assetContext->getAreaCode(), 'themeModel' => $this->themeList->getThemeByFullPath($assetContext->getAreaCode() . '/' . $assetContext->getThemePath())]);
 }
Пример #10
0
 /**
  * Retrieve config view
  *
  * @return \Magento\Framework\Config\View
  */
 protected function getConfigView()
 {
     if (!$this->configView) {
         $this->configView = $this->viewConfig->getViewConfig();
     }
     return $this->configView;
 }
Пример #11
0
 /**
  * Initialize view configurations
  *
  * @return $this
  */
 protected function _initViewConfigs()
 {
     $this->_viewConfig = $this->_viewConfigLoader->getViewConfig(array('area' => \Magento\Framework\View\DesignInterface::DEFAULT_AREA, 'themeModel' => $this->_theme));
     $this->_viewConfigParent = $this->_viewConfigLoader->getViewConfig(array('area' => \Magento\Framework\View\DesignInterface::DEFAULT_AREA, 'themeModel' => $this->_parentTheme));
     return $this;
 }
Пример #12
0
 /**
  * Retrieve quote item data
  *
  * @return array
  */
 private function getQuoteItemData()
 {
     $quoteItemData = [];
     $quoteId = $this->checkoutSession->getQuote()->getId();
     if ($quoteId) {
         $quoteItems = $this->quoteItemRepository->getList($quoteId);
         foreach ($quoteItems as $index => $quoteItem) {
             $quoteItemData[$index] = $quoteItem->toArray();
             $quoteItemData[$index]['options'] = $this->getFormattedOptionValue($quoteItem);
             $thumbnailSize = $this->viewConfig->getViewConfig()->getVarValue('Magento_Catalog', 'product_thumbnail_image_size');
             $quoteItemData[$index]['thumbnail'] = (string) $this->imageHelper->init($quoteItem->getProduct(), 'thumbnail')->resize($thumbnailSize);
         }
     }
     return $quoteItemData;
 }