Skip to content

Commit 92debd3

Browse files
author
Viktor Sevch
committed
MC-38254: Minor changes in downloadcss controller
1 parent 966d930 commit 92debd3

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme/DownloadCss.php

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66
*/
77
namespace Magento\Theme\Controller\Adminhtml\System\Design\Theme;
88

9-
use Magento\Backend\App\Action\Context;
109
use Magento\Framework\App\Action\HttpGetActionInterface;
11-
use Magento\Framework\App\Response\Http\FileFactory;
1210
use Magento\Framework\App\ResponseInterface;
1311
use Magento\Framework\App\Filesystem\DirectoryList;
14-
use Magento\Framework\Escaper;
15-
use Magento\Framework\Filesystem;
16-
use Magento\Framework\Registry;
12+
use Magento\Theme\Controller\Adminhtml\System\Design\Theme;
1713
use Magento\Framework\Url\DecoderInterface;
18-
use Magento\Framework\View\Asset\Repository;
1914
use Magento\Framework\View\Design\ThemeInterface;
20-
use Magento\Theme\Controller\Adminhtml\System\Design\Theme;
2115
use Psr\Log\LoggerInterface;
2216

2317
/**
@@ -28,32 +22,6 @@
2822
*/
2923
class DownloadCss extends Theme implements HttpGetActionInterface
3024
{
31-
/**
32-
* @var Escaper
33-
*/
34-
private $escaper;
35-
36-
/**
37-
* DownloadCss constructor.
38-
* @param Context $context
39-
* @param Registry $coreRegistry
40-
* @param FileFactory $fileFactory
41-
* @param Repository $assetRepo
42-
* @param Filesystem $appFileSystem
43-
* @param Escaper|null $escaper
44-
*/
45-
public function __construct(
46-
Context $context,
47-
Registry $coreRegistry,
48-
FileFactory $fileFactory,
49-
Repository $assetRepo,
50-
Filesystem $appFileSystem,
51-
Escaper $escaper = null
52-
) {
53-
$this->escaper = $escaper ?? $context->getObjectManager()->get(Escaper::class);
54-
parent::__construct($context, $coreRegistry, $fileFactory, $assetRepo, $appFileSystem);
55-
}
56-
5725
/**
5826
* Download css file
5927
*
@@ -86,11 +54,11 @@ public function execute()
8654
DirectoryList::ROOT
8755
);
8856
} catch (\InvalidArgumentException $e) {
89-
$this->messageManager->addException($e, __('Theme not found: "%1".', $this->escaper->escapeHtml($themeId)));
57+
$this->messageManager->addException($e, sprintf('Theme not found: "%d".', $themeId));
9058
$this->getResponse()->setRedirect($this->_redirect->getRefererUrl());
9159
$this->_objectManager->get(LoggerInterface::class)->critical($e);
9260
} catch (\Exception $e) {
93-
$this->messageManager->addException($e, __('File not found: "%1".', $this->escaper->escapeHtml($fileId)));
61+
$this->messageManager->addException($e, sprintf('File not found: "%d".', $fileId));
9462
$this->getResponse()->setRedirect($this->_redirect->getRefererUrl());
9563
$this->_objectManager->get(LoggerInterface::class)->critical($e);
9664
}

app/code/Magento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Theme/DownloadCssTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Magento\Framework\App\Response\RedirectInterface;
1515
use Magento\Framework\App\ResponseInterface;
1616
use Magento\Framework\Controller\ResultFactory;
17-
use Magento\Framework\Escaper;
1817
use Magento\Framework\Filesystem;
1918
use Magento\Framework\Filesystem\Directory\ReadInterface;
2019
use Magento\Framework\Message\ManagerInterface;
@@ -89,11 +88,6 @@ class DownloadCssTest extends TestCase
8988
*/
9089
protected $controller;
9190

92-
/**
93-
* @var Escaper|MockObject
94-
*/
95-
private $escaperMock;
96-
9791
protected function setUp(): void
9892
{
9993
$context = $this->getMockBuilder(Context::class)
@@ -129,18 +123,14 @@ protected function setUp(): void
129123
$this->filesystem = $this->getMockBuilder(Filesystem::class)
130124
->disableOriginalConstructor()
131125
->getMock();
132-
$this->escaperMock = $this->getMockBuilder(Escaper::class)
133-
->disableOriginalConstructor()
134-
->getMock();
135126

136127
/** @var Context $context */
137128
$this->controller = new DownloadCss(
138129
$context,
139130
$this->registry,
140131
$this->fileFactory,
141132
$this->repository,
142-
$this->filesystem,
143-
$this->escaperMock
133+
$this->filesystem
144134
);
145135
}
146136

@@ -241,7 +231,6 @@ public function testExecuteInvalidArgument()
241231
$logger->expects($this->once())->method('critical');
242232
$this->redirect->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl);
243233
$this->response->expects($this->once())->method('setRedirect')->with($refererUrl);
244-
$this->escaperMock->expects($this->once())->method('escapeHtml')->with($themeId)->willReturn($themeId);
245234

246235
$this->controller->execute();
247236
}

0 commit comments

Comments
 (0)