Example #1
0
 /**
  * Create a form element with necessary controls
  *
  * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\QuickStyles\Header
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _prepareForm()
 {
     if (!$this->_formId || !$this->_tab) {
         throw new \Magento\Framework\Exception\LocalizedException(__('We found an invalid block of class "%1". Please define the required properties.', get_class($this)));
     }
     $form = $this->_formBuilder->create(['id' => $this->_formId, 'action' => '#', 'method' => 'post', 'tab' => $this->_tab, 'theme' => $this->_themeContext->getStagingTheme(), 'parent_theme' => $this->_themeContext->getEditableTheme()->getParentTheme()]);
     $form->setUseContainer(true);
     $this->setForm($form);
     parent::_prepareForm();
     return $this;
 }
Example #2
0
 /**
  * Create a form element with necessary controls
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var Form $form */
     $form = $this->_formFactory->create(['data' => ['action' => '#', 'method' => 'post']]);
     $form->setId('product_image_sizing_form');
     $this->setForm($form);
     $form->setUseContainer(true);
     $form->setFieldNameSuffix('imagesizing');
     $form->addType('button_button', 'Magento\\DesignEditor\\Block\\Adminhtml\\Editor\\Form\\Element\\Button');
     $isFilePresent = true;
     try {
         /** @var $controlsConfig Configuration */
         $controlsConfig = $this->_controlFactory->create(\Magento\DesignEditor\Model\Editor\Tools\Controls\Factory::TYPE_IMAGE_SIZING, $this->_themeContext->getStagingTheme());
     } catch (\Magento\Framework\Exception $e) {
         $isFilePresent = false;
     }
     if ($isFilePresent) {
         $this->_initFormElements($controlsConfig, $form);
     } else {
         $hintMessage = __('Sorry, but you cannot resize images for this theme.');
         $form->addField('imagesize-tab-error', 'note', ['after_element_html' => '<p class="error-notice">' . $hintMessage . '</p>']);
     }
     return parent::_prepareForm();
 }
Example #3
0
 /**
  * @expectedException \Magento\Framework\Model\Exception
  * @expectedExceptionMessage Theme "" is not editable.
  */
 public function testGetStagingThemeWrongType()
 {
     $this->_setEditableTheme();
     $this->_theme->expects($this->atLeastOnce())->method('isVirtual')->will($this->returnValue(false));
     $this->_model->getStagingTheme();
 }
Example #4
0
 /**
  * Check themes by change time (compare staging and physical theme)
  *
  * @return bool
  */
 protected function _isAbleRevertToDefault()
 {
     return $this->_hasThemeChanged($this->_themeContext->getStagingTheme(), $this->_themeContext->getEditableTheme()->getParentTheme());
 }
Example #5
0
 /**
  * Get custom js files
  *
  * @return \Magento\Core\Model\Resource\Theme\File\Collection
  */
 public function getFiles()
 {
     $customization = $this->_themeContext->getStagingTheme()->getCustomization();
     $jsFiles = $customization->getFilesByType(\Magento\Framework\View\Design\Theme\Customization\File\Js::TYPE);
     return $this->_coreHelper->jsonEncode($customization->generateFileInfo($jsFiles));
 }
Example #6
0
 /**
  * Get custom CSS file name
  *
  * @return string|null
  */
 public function getCustomFileName()
 {
     $customCss = $this->_getCustomCss($this->_themeContext->getStagingTheme());
     return $customCss ? $customCss->getFileName() : null;
 }