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


PHP ThemeInterface::getThemeImage方法代碼示例

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


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

示例1: _addThemeFieldset

 /**
  * Add theme fieldset
  *
  * @param \Magento\Framework\Data\Form $form
  * @param array $formData
  * @param ThemeInterface $theme
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _addThemeFieldset($form, $formData, ThemeInterface $theme)
 {
     $themeFieldset = $form->addFieldset('theme', ['legend' => __('Theme Settings')]);
     $this->_addElementTypes($themeFieldset);
     if (isset($formData['theme_id'])) {
         $themeFieldset->addField('theme_id', 'hidden', ['name' => 'theme_id']);
     }
     /** @var \Magento\Theme\Model\Theme\Collection $themesCollections */
     $themesCollections = $this->_objectManager->create('Magento\\Theme\\Model\\Theme\\Collection');
     /** @var \Magento\Framework\Json\Helper\Data $helper */
     $helper = $this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data');
     $onChangeScript = sprintf('parentThemeOnChange(this.value, %s)', str_replace('"', '\'', $helper->jsonEncode($this->_getDefaultsInherited($themesCollections->addDefaultPattern()))));
     /** @var ThemeInterface $parentTheme */
     $parentTheme = $this->_objectManager->create('Magento\\Framework\\View\\Design\\ThemeInterface');
     if (!empty($formData['parent_id'])) {
         $parentTheme->load($formData['parent_id']);
     }
     if ($this->_getCurrentTheme()->isObjectNew()) {
         $themeFieldset->addField('parent_id', 'select', ['label' => __('Parent Theme'), 'title' => __('Parent Theme'), 'name' => 'parent_id', 'values' => $themesCollections->toOptionArray(!$parentTheme->getId()), 'required' => true, 'class' => 'no-changes', 'onchange' => $onChangeScript]);
     } elseif (!empty($formData['parent_id'])) {
         $themeFieldset->addField('parent_title', 'note', ['label' => __('Parent Theme'), 'title' => __('Parent Theme'), 'name' => 'parent_title', 'text' => $parentTheme->getId() ? $parentTheme->getThemeTitle() : '']);
     }
     if (!empty($formData['theme_path'])) {
         $themeFieldset->addField('theme_path', 'label', ['label' => __('Theme Path'), 'title' => __('Theme Path'), 'name' => 'theme_code']);
     }
     $themeFieldset->addField('theme_title', $this->_getFieldTextType(), ['label' => __('Theme Title'), 'title' => __('Theme Title'), 'name' => 'theme_title', 'required' => $this->_isFieldAttrRequired()]);
     if ($this->_isThemeEditable) {
         $themeFieldset->addField('preview_image', 'image', ['label' => __('Theme Preview Image'), 'title' => __('Theme Preview Image'), 'name' => 'preview', 'required' => false, 'note' => $this->_getPreviewImageNote(), 'theme' => $theme]);
     } elseif ($theme->hasPreviewImage()) {
         $themeFieldset->addField('preview_image', 'note', ['label' => __('Theme Preview Image'), 'title' => __('Theme Preview Image'), 'name' => 'preview', 'after_element_html' => '<a href="' . $theme->getThemeImage()->getPreviewImageUrl() . '" onclick="imagePreview(\'theme_preview_image\'); return false;">' . '<img width="50" src="' . $theme->getThemeImage()->getPreviewImageUrl() . '" id="theme_preview_image" /></a>']);
     }
     return $this;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:42,代碼來源:General.php

示例2: _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

示例3: createPreviewImageCopy

 /**
  * Create preview image duplicate
  *
  * @param ThemeInterface $theme
  * @return bool
  */
 public function createPreviewImageCopy(ThemeInterface $theme)
 {
     $previewDir = $this->themeImagePath->getImagePreviewDirectory();
     $sourcePath = $theme->getThemeImage()->getPreviewImagePath();
     $sourceRelativePath = $this->rootDirectory->getRelativePath($sourcePath);
     if (!$theme->getPreviewImage() && !$this->mediaDirectory->isExist($sourceRelativePath)) {
         return false;
     }
     $isCopied = false;
     try {
         $destinationFileName = \Magento\Framework\File\Uploader::getNewFileName($sourcePath);
         $targetRelativePath = $this->mediaDirectory->getRelativePath($previewDir . '/' . $destinationFileName);
         $isCopied = $this->rootDirectory->copyFile($sourceRelativePath, $targetRelativePath, $this->mediaDirectory);
         $this->theme->setPreviewImage($destinationFileName);
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         $this->theme->setPreviewImage(null);
         $this->logger->critical($e);
     }
     return $isCopied;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:26,代碼來源:Image.php


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