Exemple #1
0
 /**
  * Create a form element with necessary controls
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $this->setForm($form);
     $this->_addThemeCssFieldset();
     $customFiles = $this->_getCurrentTheme()->getCustomization()->getFilesByType(\Magento\Theme\Model\Theme\Customization\File\CustomCss::TYPE);
     $this->_customCssFile = reset($customFiles);
     $this->_addCustomCssFieldset();
     $formData['custom_css_content'] = $this->_customCssFile ? $this->_customCssFile->getContent() : null;
     /** @var $session \Magento\Backend\Model\Session */
     $session = $this->_objectManager->get('Magento\\Backend\\Model\\Session');
     $cssFileContent = $session->getThemeCustomCssData();
     if ($cssFileContent) {
         $formData['custom_css_content'] = $cssFileContent;
         $session->unsThemeCustomCssData();
     }
     $form->addValues($formData);
     parent::_prepareForm();
     return $this;
 }
Exemple #2
0
 /**
  * Test crud operations for theme files model using valid data
  */
 public function testCrud()
 {
     $this->_model->setData($this->_data);
     $crud = new \Magento\TestFramework\Entity($this->_model, array('file_path' => 'rename.css'));
     $crud->testCrud();
 }