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


PHP ThemeInterface::getCustomization方法代碼示例

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


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

示例1: _copyDatabaseCustomization

 /**
  * Copy customizations stored in a database from one theme to another, overriding existing data
  *
  * @param ThemeInterface $source
  * @param ThemeInterface $target
  * @return void
  */
 protected function _copyDatabaseCustomization(ThemeInterface $source, ThemeInterface $target)
 {
     /** @var $themeFile \Magento\Theme\Model\Theme\File */
     foreach ($target->getCustomization()->getFiles() as $themeFile) {
         $themeFile->delete();
     }
     /** @var $newFile \Magento\Theme\Model\Theme\File */
     foreach ($source->getCustomization()->getFiles() as $themeFile) {
         /** @var $newThemeFile \Magento\Theme\Model\Theme\File */
         $newThemeFile = $this->_fileFactory->create();
         $newThemeFile->setData(['theme_id' => $target->getId(), 'file_path' => $themeFile->getFilePath(), 'file_type' => $themeFile->getFileType(), 'content' => $themeFile->getContent(), 'sort_order' => $themeFile->getData('sort_order')]);
         $newThemeFile->save();
     }
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:21,代碼來源:CopyService.php

示例2: update

 /**
  * Creates or updates custom single file which belong to a selected theme
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $themeModel
  * @param string $fileContent
  * @return \Magento\Framework\View\Design\Theme\FileInterface
  */
 public function update(\Magento\Framework\View\Design\ThemeInterface $themeModel, $fileContent)
 {
     $customFiles = $themeModel->getCustomization()->getFilesByType($this->_fileService->getType());
     $customCss = reset($customFiles);
     if (empty($fileContent) && $customCss) {
         $customCss->delete();
         return $customCss;
     }
     if (!$customCss) {
         $customCss = $this->_fileService->create();
     }
     $customCss->setData('content', $fileContent);
     $customCss->setTheme($themeModel);
     $customCss->save();
     return $customCss;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:23,代碼來源:SingleFile.php

示例3: _savePreviewImage

 /**
  * Save preview image for theme
  *
  * @param ThemeInterface $theme
  * @return $this
  */
 protected function _savePreviewImage(ThemeInterface $theme)
 {
     $themeDirectory = $theme->getCustomization()->getThemeFilesPath();
     if (!$theme->getPreviewImage() || !$themeDirectory) {
         return $this;
     }
     $imagePath = $themeDirectory . '/' . $theme->getPreviewImage();
     if (0 === strpos($imagePath, $themeDirectory)) {
         $theme->getThemeImage()->createPreviewImage($imagePath);
     }
     return $this;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:Registration.php

示例4: _getCustomCss

 /**
  * Get theme file (with custom CSS)
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return \Magento\Framework\View\Design\Theme\FileInterface|null
  */
 protected function _getCustomCss($theme)
 {
     $files = $theme->getCustomization()->getFilesByType(\Magento\Theme\Model\Theme\Customization\File\CustomCss::TYPE);
     return reset($files);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:11,代碼來源:Custom.php


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