1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Theme\Controller\Adminhtml\System\Design\Theme;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
/**
* Class DownloadCss
* @deprecated 100.2.0
*/
class DownloadCss extends \Magento\Theme\Controller\Adminhtml\System\Design\Theme
{
/**
* Download css file
*
* @return ResponseInterface|void
*/
public function execute()
{
$themeId = $this->getRequest()->getParam('theme_id');
$file = $this->getRequest()->getParam('file');
/** @var $urlDecoder \Magento\Framework\Url\DecoderInterface */
$urlDecoder = $this->_objectManager->get(\Magento\Framework\Url\DecoderInterface::class);
$fileId = $urlDecoder->decode($file);
try {
/** @var $theme \Magento\Framework\View\Design\ThemeInterface */
$theme = $this->_objectManager->create(
\Magento\Framework\View\Design\ThemeInterface::class
)->load($themeId);
if (!$theme->getId()) {
throw new \InvalidArgumentException(sprintf('Theme not found: "%1".', $themeId));
}
$asset = $this->_assetRepo->createAsset($fileId, ['themeModel' => $theme]);
$relPath = $this->_appFileSystem->getDirectoryRead(DirectoryList::ROOT)
->getRelativePath($asset->getSourceFile());
return $this->_fileFactory->create(
$relPath,
[
'type' => 'filename',
'value' => $relPath
],
DirectoryList::ROOT
);
} catch (\Exception $e) {
$this->messageManager->addException($e, __('File not found: "%1".', $fileId));
$this->getResponse()->setRedirect($this->_redirect->getRefererUrl());
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
}
}
}