Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExportVarnishConfig.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
16  const ADMIN_RESOURCE = 'Magento_Backend::system';
17 
21  protected $fileFactory;
22 
26  protected $config;
27 
33  public function __construct(
34  \Magento\Backend\App\Action\Context $context,
35  \Magento\Framework\App\Response\Http\FileFactory $fileFactory,
36  \Magento\PageCache\Model\Config $config
37  ) {
38  parent::__construct($context);
39  $this->config = $config;
40  $this->fileFactory = $fileFactory;
41  }
42 
48  public function execute()
49  {
50  $fileName = 'varnish.vcl';
51  $varnishVersion = $this->getRequest()->getParam('varnish');
52  switch ($varnishVersion) {
53  case 5:
54  $content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_5_CONFIGURATION_PATH);
55  break;
56  default:
57  $content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_4_CONFIGURATION_PATH);
58  break;
59  }
60  return $this->fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
61  }
62 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\PageCache\Model\Config $config)
$fileName
Definition: translate.phtml:15