本文整理匯總了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;
}
示例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}";
}
示例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;
}