Skip to content

Commit 2176873

Browse files
committed
MC-18031: Create Varnish 6 template for export. Implemented
1 parent 8823790 commit 2176873

File tree

6 files changed

+60
-2
lines changed

6 files changed

+60
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\PageCache\Block\System\Config\Form\Field\Export;
7+
8+
/**
9+
* Class Export
10+
*/
11+
class Varnish6 extends \Magento\PageCache\Block\System\Config\Form\Field\Export
12+
{
13+
/**
14+
* Return Varnish version to this class
15+
*
16+
* @return int
17+
*/
18+
public function getVarnishVersion()
19+
{
20+
return 6;
21+
}
22+
}

app/code/Magento/PageCache/Controller/Adminhtml/PageCache/ExportVarnishConfig.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public function execute()
5050
$fileName = 'varnish.vcl';
5151
$varnishVersion = $this->getRequest()->getParam('varnish');
5252
switch ($varnishVersion) {
53+
case 6:
54+
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_6_CONFIGURATION_PATH);
55+
break;
5356
case 5:
5457
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_5_CONFIGURATION_PATH);
5558
break;

app/code/Magento/PageCache/Model/Config.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class Config
4949
*/
5050
protected $_scopeConfig;
5151

52+
/**
53+
* XML path to Varnish 5 config template path
54+
*/
55+
const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';
56+
5257
/**
5358
* XML path to Varnish 5 config template path
5459
*/
@@ -145,8 +150,16 @@ public function getVclFile($vclTemplatePath)
145150
self::XML_VARNISH_PAGECACHE_DESIGN_THEME_REGEX,
146151
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
147152
);
148-
149-
$version = $vclTemplatePath === self::VARNISH_5_CONFIGURATION_PATH ? 5 : 4;
153+
switch ($vclTemplatePath) {
154+
case self::VARNISH_6_CONFIGURATION_PATH:
155+
$version = 6;
156+
break;
157+
case self::VARNISH_5_CONFIGURATION_PATH:
158+
$version = 5;
159+
break;
160+
default:
161+
$version = 4;
162+
}
150163
$sslOffloadedHeader = $this->_scopeConfig->getValue(
151164
\Magento\Framework\HTTP\PhpEnvironment\Request::XML_PATH_OFFLOADER_HEADER
152165
);

app/code/Magento/PageCache/Model/Varnish/VclTemplateLocator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
class VclTemplateLocator implements VclTemplateLocatorInterface
1717
{
18+
/**
19+
* XML path to Varnish 5 config template path
20+
*/
21+
const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';
22+
1823
/**
1924
* XML path to Varnish 5 config template path
2025
*/
@@ -35,12 +40,18 @@ class VclTemplateLocator implements VclTemplateLocatorInterface
3540
*/
3641
const VARNISH_SUPPORTED_VERSION_5 = '5';
3742

43+
/**
44+
*
45+
*/
46+
const VARNISH_SUPPORTED_VERSION_6 = '6';
47+
3848
/**
3949
* @var array
4050
*/
4151
private $supportedVarnishVersions = [
4252
self::VARNISH_SUPPORTED_VERSION_4 => self::VARNISH_4_CONFIGURATION_PATH,
4353
self::VARNISH_SUPPORTED_VERSION_5 => self::VARNISH_5_CONFIGURATION_PATH,
54+
self::VARNISH_SUPPORTED_VERSION_6 => self::VARNISH_6_CONFIGURATION_PATH,
4455
];
4556

4657
/**

app/code/Magento/PageCache/etc/adminhtml/system.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
<field id="caching_application">1</field>
6363
</depends>
6464
</field>
65+
<field id="export_button_version6" type="button" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
66+
<frontend_model>Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish6</frontend_model>
67+
<depends>
68+
<field id="caching_application">1</field>
69+
</depends>
70+
</field>
6571
<depends>
6672
<field id="caching_application">2</field>
6773
</depends>

app/code/Magento/PageCache/etc/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
</design>
1515
<system>
1616
<full_page_cache>
17+
<varnish6>
18+
<path>varnish6.vcl</path>
19+
</varnish6>
1720
<varnish5>
1821
<path>varnish5.vcl</path>
1922
</varnish5>

0 commit comments

Comments
 (0)