config = $config; $this->fileFactory = $fileFactory; } /** * Export Varnish Configuration as .vcl * * @return \Magento\Framework\App\ResponseInterface */ public function execute() { $fileName = 'varnish.vcl'; $varnishVersion = $this->getRequest()->getParam('varnish'); switch ($varnishVersion) { case 5: $content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_5_CONFIGURATION_PATH); break; default: $content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_4_CONFIGURATION_PATH); break; } return $this->fileFactory->create($fileName, $content, DirectoryList::VAR_DIR); } }