本文整理匯總了PHP中Magento\Framework\View\Design\ThemeInterface::hasPreviewImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP ThemeInterface::hasPreviewImage方法的具體用法?PHP ThemeInterface::hasPreviewImage怎麽用?PHP ThemeInterface::hasPreviewImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\Design\ThemeInterface
的用法示例。
在下文中一共展示了ThemeInterface::hasPreviewImage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}