Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UploadCss.php
Go to the documentation of this file.
1 <?php
8 
14 {
20  public function execute()
21  {
23  $serviceModel = $this->_objectManager->get(\Magento\Theme\Model\Uploader\Service::class);
24  try {
25  $cssFileContent = $serviceModel->uploadCssFile('css_file_uploader');
26  $result = ['error' => false, 'content' => $cssFileContent['content']];
27  } catch (\Magento\Framework\Exception\LocalizedException $e) {
28  $result = ['error' => true, 'message' => $e->getMessage()];
29  } catch (\Exception $e) {
30  $result = ['error' => true, 'message' => __('We can\'t upload the CSS file right now.')];
31  $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
32  }
33  $this->getResponse()->representJson(
34  $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($result)
35  );
36  }
37 }
__()
Definition: __.php:13