當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ThemeInterface::getArea方法代碼示例

本文整理匯總了PHP中Magento\Framework\View\Design\ThemeInterface::getArea方法的典型用法代碼示例。如果您正苦於以下問題:PHP ThemeInterface::getArea方法的具體用法?PHP ThemeInterface::getArea怎麽用?PHP ThemeInterface::getArea使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\View\Design\ThemeInterface的用法示例。


在下文中一共展示了ThemeInterface::getArea方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getCssAssets

 /**
  * Get CSS files of a given theme
  *
  * Returns an associative array of local assets with FileId used as keys:
  * array('Magento_Catalog::widgets.css' => \Magento\Framework\View\Asset\LocalInterface)
  * The array will be sorted by keys
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return \Magento\Framework\View\Asset\LocalInterface[]
  */
 public function getCssAssets($theme)
 {
     /** @var $layoutProcessor \Magento\Framework\View\Layout\ProcessorInterface */
     $layoutProcessor = $this->_layoutProcessorFactory->create(['theme' => $theme]);
     $layoutElement = $layoutProcessor->getFileLayoutUpdatesXml();
     /**
      * XPath selector to get CSS files from layout added for HEAD block directly
      */
     $xpathSelectorBlocks = '//block[@class="Magento\\Theme\\Block\\Html\\Head"]' . '/block[@class="Magento\\Theme\\Block\\Html\\Head\\Css"]/arguments/argument[@name="file"]';
     /**
      * XPath selector to get CSS files from layout added for HEAD block using reference
      */
     $xpathSelectorRefs = '//referenceBlock[@name="head"]' . '/block[@class="Magento\\Theme\\Block\\Html\\Head\\Css"]/arguments/argument[@name="file"]';
     $elements = array_merge($layoutElement->xpath($xpathSelectorBlocks) ?: [], $layoutElement->xpath($xpathSelectorRefs) ?: []);
     $params = ['area' => $theme->getArea(), 'themeModel' => $theme];
     $result = [];
     foreach ($elements as $fileId) {
         $fileId = (string) $fileId;
         $result[$fileId] = $this->_assetRepo->createAsset($fileId, $params);
     }
     ksort($result);
     return $result;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:33,代碼來源:Theme.php

示例2: generateCacheId

 /**
  * Generate cache identifier taking into account current area/package/theme/store
  *
  * @param string $suffix
  * @return string
  */
 protected function generateCacheId($suffix = '')
 {
     return "LAYOUT_{$this->theme->getArea()}_STORE{$this->scope->getId()}_{$this->theme->getId()}{$suffix}";
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:10,代碼來源:Merge.php

示例3: getFiles

 /**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $result = [];
     $namespace = $module = '*';
     $sharedFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/base/{$this->subDir}{$filePath}");
     $filePathPtn = strtr(preg_quote($filePath), array('\\*' => '[^/]+'));
     $pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/base/{$this->subDir}" . $filePathPtn . "\$#i";
     foreach ($sharedFiles as $file) {
         $filename = $this->modulesDirectory->getAbsolutePath($file);
         if (!preg_match($pattern, $filename, $matches)) {
             continue;
         }
         $moduleFull = "{$matches['namespace']}_{$matches['module']}";
         $result[] = $this->fileFactory->create($filename, $moduleFull, null, true);
     }
     $area = $theme->getArea();
     $themeFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/{$area}/{$this->subDir}{$filePath}");
     $pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/{$area}/{$this->subDir}" . $filePathPtn . "\$#i";
     foreach ($themeFiles as $file) {
         $filename = $this->modulesDirectory->getAbsolutePath($file);
         if (!preg_match($pattern, $filename, $matches)) {
             continue;
         }
         $moduleFull = "{$matches['namespace']}_{$matches['module']}";
         $result[] = $this->fileFactory->create($filename, $moduleFull);
     }
     return $result;
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:35,代碼來源:Base.php


注:本文中的Magento\Framework\View\Design\ThemeInterface::getArea方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。