_fileService = $fileService; } /** * 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; } }