Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DownloadCss.php
Go to the documentation of this file.
1 <?php
8 
11 
17 {
23  public function execute()
24  {
25  $themeId = $this->getRequest()->getParam('theme_id');
26  $file = $this->getRequest()->getParam('file');
27 
29  $urlDecoder = $this->_objectManager->get(\Magento\Framework\Url\DecoderInterface::class);
30  $fileId = $urlDecoder->decode($file);
31  try {
33  $theme = $this->_objectManager->create(
34  \Magento\Framework\View\Design\ThemeInterface::class
35  )->load($themeId);
36  if (!$theme->getId()) {
37  throw new \InvalidArgumentException(sprintf('Theme not found: "%1".', $themeId));
38  }
39  $asset = $this->_assetRepo->createAsset($fileId, ['themeModel' => $theme]);
40  $relPath = $this->_appFileSystem->getDirectoryRead(DirectoryList::ROOT)
41  ->getRelativePath($asset->getSourceFile());
42  return $this->_fileFactory->create(
43  $relPath,
44  [
45  'type' => 'filename',
46  'value' => $relPath
47  ],
48  DirectoryList::ROOT
49  );
50  } catch (\Exception $e) {
51  $this->messageManager->addException($e, __('File not found: "%1".', $fileId));
52  $this->getResponse()->setRedirect($this->_redirect->getRefererUrl());
53  $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
54  }
55  }
56 }
__()
Definition: __.php:13
$theme