Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-page-cache
Model
Varnish
VclTemplateLocator.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\PageCache\Model\Varnish
;
8
9
use
Magento\Framework\App\Config\ScopeConfigInterface
;
10
use
Magento\Framework\Module\Dir
;
11
use
Magento\Framework\Module\Dir\Reader
;
12
use
Magento\Framework\Filesystem\Directory\ReadFactory
;
13
use
Magento\PageCache\Model\VclTemplateLocatorInterface
;
14
use
Magento\PageCache\Exception\UnsupportedVarnishVersion
;
15
16
class
VclTemplateLocator
implements
VclTemplateLocatorInterface
17
{
21
const
VARNISH_5_CONFIGURATION_PATH
=
'system/full_page_cache/varnish5/path'
;
22
26
const
VARNISH_4_CONFIGURATION_PATH
=
'system/full_page_cache/varnish4/path'
;
27
31
const
VARNISH_SUPPORTED_VERSION_4
=
'4'
;
32
36
const
VARNISH_SUPPORTED_VERSION_5
=
'5'
;
37
41
private
$supportedVarnishVersions = [
42
self::VARNISH_SUPPORTED_VERSION_4 =>
self::VARNISH_4_CONFIGURATION_PATH
,
43
self::VARNISH_SUPPORTED_VERSION_5 =>
self::VARNISH_5_CONFIGURATION_PATH
,
44
];
45
49
private
$reader;
50
54
private
$readFactory;
55
59
private
$scopeConfig;
60
68
public
function
__construct
(
Reader
$reader,
ReadFactory
$readFactory,
ScopeConfigInterface
$scopeConfig)
69
{
70
$this->reader = $reader;
71
$this->readFactory = $readFactory;
72
$this->scopeConfig = $scopeConfig;
73
}
74
78
public
function
getTemplate
(
$version
)
79
{
80
$moduleEtcPath = $this->reader->getModuleDir(
Dir::MODULE_ETC_DIR
,
'Magento_PageCache'
);
81
$configFilePath = $moduleEtcPath .
'/'
. $this->scopeConfig->getValue($this->getVclTemplatePath(
$version
));
82
$directoryRead = $this->readFactory->create($moduleEtcPath);
83
$configFilePath = $directoryRead->getRelativePath($configFilePath);
84
$template
= $directoryRead->readFile($configFilePath);
85
return
$template
;
86
}
87
95
private
function
getVclTemplatePath(
$version
)
96
{
97
if
(!isset($this->supportedVarnishVersions[
$version
])) {
98
throw
new
UnsupportedVarnishVersion
(
__
(
'Unsupported varnish version'
));
99
}
100
101
return
$this->supportedVarnishVersions[
$version
];
102
}
103
}
Magento\PageCache\Model\VclTemplateLocatorInterface
Definition:
VclTemplateLocatorInterface.php:17
Magento\Framework\Module\Dir
Definition:
Reader.php:8
Magento\Framework\Module\Dir\MODULE_ETC_DIR
const MODULE_ETC_DIR
Definition:
Dir.php:18
Magento\PageCache\Model\Varnish\VclTemplateLocator
Definition:
VclTemplateLocator.php:16
Magento\PageCache\Model\Varnish\VclTemplateLocator\VARNISH_4_CONFIGURATION_PATH
const VARNISH_4_CONFIGURATION_PATH
Definition:
VclTemplateLocator.php:26
$version
$version
Definition:
pre_composer_update_2.3.php:161
Magento\PageCache\Exception\UnsupportedVarnishVersion
Definition:
UnsupportedVarnishVersion.php:11
__
__()
Definition:
__.php:13
Magento\Framework\Filesystem\Directory\ReadFactory
Definition:
ReadFactory.php:10
Magento\PageCache\Model\Varnish\VclTemplateLocator\getTemplate
getTemplate($version)
Definition:
VclTemplateLocator.php:78
Magento\PageCache\Model\Varnish\VclTemplateLocator\VARNISH_5_CONFIGURATION_PATH
const VARNISH_5_CONFIGURATION_PATH
Definition:
VclTemplateLocator.php:21
Magento\PageCache\Model\Varnish\VclTemplateLocator\__construct
__construct(Reader $reader, ReadFactory $readFactory, ScopeConfigInterface $scopeConfig)
Definition:
VclTemplateLocator.php:68
Magento\PageCache\Model\Varnish\VclTemplateLocator\VARNISH_SUPPORTED_VERSION_5
const VARNISH_SUPPORTED_VERSION_5
Definition:
VclTemplateLocator.php:36
Magento\PageCache\Model\Varnish\VclTemplateLocator\VARNISH_SUPPORTED_VERSION_4
const VARNISH_SUPPORTED_VERSION_4
Definition:
VclTemplateLocator.php:31
Magento\Framework\App\Config\ScopeConfigInterface
Definition:
ScopeConfigInterface.php:15
Magento\PageCache\Model\Varnish
Definition:
VclGenerator.php:7
$template
$template
Definition:
export.php:12
Magento\Framework\Module\Dir\Reader
Definition:
Reader.php:20