![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/magento/module-theme/Model/Theme/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ /** * Service model to upload single file in customizations */ namespace Magento\Theme\Model\Theme; class SingleFile { /** * @var \Magento\Framework\View\Design\Theme\Customization\FileInterface */ protected $_fileService; /** * @param \Magento\Framework\View\Design\Theme\Customization\FileInterface $fileService */ public function __construct(\Magento\Framework\View\Design\Theme\Customization\FileInterface $fileService) { $this->_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; } }