Skip to content

Commit fe92b56

Browse files
committed
ACP2E-2102: No Export VCL for Varnish 7 button in admin panel
1 parent c22a9db commit fe92b56

File tree

8 files changed

+384
-12
lines changed

8 files changed

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

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ExportVarnishConfig extends \Magento\Backend\App\Action implements HttpGet
1616
/**
1717
* Authorization level of a basic admin session
1818
*/
19-
const ADMIN_RESOURCE = 'Magento_Backend::system';
19+
public const ADMIN_RESOURCE = 'Magento_Backend::system';
2020

2121
/**
2222
* @var \Magento\Backend\App\Response\Http\FileFactory
@@ -53,6 +53,9 @@ public function execute()
5353
$fileName = 'varnish.vcl';
5454
$varnishVersion = $this->getRequest()->getParam('varnish');
5555
switch ($varnishVersion) {
56+
case 7:
57+
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_7_CONFIGURATION_PATH);
58+
break;
5659
case 6:
5760
$content = $this->config->getVclFile(\Magento\PageCache\Model\Config::VARNISH_6_CONFIGURATION_PATH);
5861
break;

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class Config
5151
*/
5252
protected $_scopeConfig;
5353

54+
/**
55+
* XML path to Varnish 7 config template path
56+
*/
57+
public const VARNISH_7_CONFIGURATION_PATH = 'system/full_page_cache/varnish7/path';
58+
5459
/**
5560
* XML path to Varnish 6 config template path
5661
*/
@@ -140,7 +145,8 @@ public function getTtl()
140145
*
141146
* @param string $vclTemplatePath
142147
* @return string
143-
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
148+
* @deprecated 100.2.0
149+
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
144150
*/
145151
public function getVclFile($vclTemplatePath)
146152
{
@@ -150,6 +156,9 @@ public function getVclFile($vclTemplatePath)
150156
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
151157
);
152158
switch ($vclTemplatePath) {
159+
case self::VARNISH_7_CONFIGURATION_PATH:
160+
$version = 7;
161+
break;
153162
case self::VARNISH_6_CONFIGURATION_PATH:
154163
$version = 6;
155164
break;
@@ -179,7 +188,8 @@ public function getVclFile($vclTemplatePath)
179188
* Prepare data for VCL config
180189
*
181190
* @return array
182-
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
191+
* @deprecated 100.2.0
192+
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
183193
*/
184194
protected function _getReplacements()
185195
{
@@ -209,7 +219,8 @@ protected function _getReplacements()
209219
* }
210220
*
211221
* @return mixed|null|string
212-
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
222+
* @deprecated 100.2.0
223+
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
213224
*/
214225
protected function _getAccessList()
215226
{
@@ -235,7 +246,8 @@ protected function _getAccessList()
235246
* we have to convert "/pattern/iU" into "(?Ui)pattern"
236247
*
237248
* @return string
238-
* @deprecated 100.2.0 see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
249+
* @deprecated 100.2.0
250+
* @see \Magento\PageCache\Model\VclGeneratorInterface::generateVcl
239251
*/
240252
protected function _getDesignExceptions()
241253
{

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,44 @@
1919
class VclTemplateLocator implements VclTemplateLocatorInterface
2020
{
2121
/**
22-
* XML path to Varnish 5 config template path
22+
* XML path to Varnish 7 config template path
23+
*/
24+
public const VARNISH_7_CONFIGURATION_PATH = 'system/full_page_cache/varnish7/path';
25+
26+
/**
27+
* XML path to Varnish 6 config template path
2328
*/
24-
const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';
29+
public const VARNISH_6_CONFIGURATION_PATH = 'system/full_page_cache/varnish6/path';
2530

2631
/**
2732
* XML path to Varnish 5 config template path
2833
*/
29-
const VARNISH_5_CONFIGURATION_PATH = 'system/full_page_cache/varnish5/path';
34+
public const VARNISH_5_CONFIGURATION_PATH = 'system/full_page_cache/varnish5/path';
3035

3136
/**
3237
* XML path to Varnish 4 config template path
3338
*/
34-
const VARNISH_4_CONFIGURATION_PATH = 'system/full_page_cache/varnish4/path';
39+
public const VARNISH_4_CONFIGURATION_PATH = 'system/full_page_cache/varnish4/path';
3540

3641
/**
3742
* Varnish 4 supported version
3843
*/
39-
const VARNISH_SUPPORTED_VERSION_4 = '4';
44+
public const VARNISH_SUPPORTED_VERSION_4 = '4';
4045

4146
/**
4247
* Varnish 5 supported version
4348
*/
44-
const VARNISH_SUPPORTED_VERSION_5 = '5';
49+
public const VARNISH_SUPPORTED_VERSION_5 = '5';
4550

4651
/**
4752
* Varnish 6 supported version
4853
*/
49-
const VARNISH_SUPPORTED_VERSION_6 = '6';
54+
public const VARNISH_SUPPORTED_VERSION_6 = '6';
55+
56+
/**
57+
* Varnish 7 supported version
58+
*/
59+
public const VARNISH_SUPPORTED_VERSION_7 = '7';
5060

5161
/**
5262
* @var array
@@ -55,6 +65,7 @@ class VclTemplateLocator implements VclTemplateLocatorInterface
5565
self::VARNISH_SUPPORTED_VERSION_4 => self::VARNISH_4_CONFIGURATION_PATH,
5666
self::VARNISH_SUPPORTED_VERSION_5 => self::VARNISH_5_CONFIGURATION_PATH,
5767
self::VARNISH_SUPPORTED_VERSION_6 => self::VARNISH_6_CONFIGURATION_PATH,
68+
self::VARNISH_SUPPORTED_VERSION_7 => self::VARNISH_7_CONFIGURATION_PATH,
5869
];
5970

6071
/**

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
<field id="caching_application">1</field>
6969
</depends>
7070
</field>
71+
<field id="export_button_version7" type="button" sortOrder="40" showInDefault="1">
72+
<frontend_model>Magento\PageCache\Block\System\Config\Form\Field\Export\Varnish7</frontend_model>
73+
<depends>
74+
<field id="caching_application">1</field>
75+
</depends>
76+
</field>
7177
<depends>
7278
<field id="caching_application">2</field>
7379
</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+
<varnish7>
18+
<path>varnish7.vcl</path>
19+
</varnish7>
1720
<varnish6>
1821
<path>varnish6.vcl</path>
1922
</varnish6>

0 commit comments

Comments
 (0)