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


PHP ThemeInterface::getData方法代碼示例

本文整理匯總了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;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:35,代碼來源:Base.php

示例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;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:21,代碼來源:Base.php

示例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;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:21,代碼來源:Physical.php

示例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());
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:10,代碼來源:Path.php


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