本文整理匯總了PHP中Magento\Framework\View\Design\ThemeInterface::getData方法的典型用法代碼示例。如果您正苦於以下問題:PHP ThemeInterface::getData方法的具體用法?PHP ThemeInterface::getData怎麽用?PHP ThemeInterface::getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\Design\ThemeInterface
的用法示例。
在下文中一共展示了ThemeInterface::getData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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), ['\\*' => '[^/]+']);
$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->getData('area');
$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;
}
示例2: getFiles
/**
* Retrieve files
*
* @param \Magento\Framework\View\Design\ThemeInterface $theme
* @param string $filePath
* @return \Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$result = [];
$sharedFiles = $this->componentDirSearch->collectFilesWithContext(ComponentRegistrar::MODULE, "view/base/{$this->subDir}{$filePath}");
foreach ($sharedFiles as $file) {
$result[] = $this->fileFactory->create($file->getFullPath(), $file->getComponentName(), null, true);
}
$area = $theme->getData('area');
$themeFiles = $this->componentDirSearch->collectFilesWithContext(ComponentRegistrar::MODULE, "view/{$area}/{$this->subDir}{$filePath}");
foreach ($themeFiles as $file) {
$result[] = $this->fileFactory->create($file->getFullPath(), $file->getComponentName());
}
return $result;
}
示例3: createVirtualTheme
/**
* Create theme customization
*
* @param \Magento\Framework\View\Design\ThemeInterface $theme
* @return \Magento\Framework\View\Design\ThemeInterface
*/
public function createVirtualTheme($theme)
{
$themeData = $theme->getData();
$themeData['parent_id'] = $theme->getId();
$themeData['theme_id'] = null;
$themeData['theme_path'] = null;
$themeData['theme_title'] = $this->_getVirtualThemeTitle($theme);
$themeData['type'] = \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL;
/** @var $themeCustomization \Magento\Framework\View\Design\ThemeInterface */
$themeCustomization = $this->_themeFactory->create()->setData($themeData);
$themeCustomization->getThemeImage()->createPreviewImageCopy($theme);
$themeCustomization->save();
$this->_themeCopyService->copy($theme, $themeCustomization);
return $themeCustomization;
}
示例4: getPreviewImagePath
/**
* Get path to preview image
*
* @param \Magento\Core\Model\Theme|ThemeInterface $theme
* @return string
*/
public function getPreviewImagePath(ThemeInterface $theme)
{
return $theme->isPhysical() ? $this->assetRepo->createAsset($theme->getPreviewImage(), ['area' => $theme->getData('area'), 'themeModel' => $theme])->getSourceFile() : $this->mediaDirectory->getAbsolutePath(self::PREVIEW_DIRECTORY_PATH . '/' . $theme->getPreviewImage());
}