File tree 2 files changed +61
-0
lines changed
2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fastly \Cdn \Model \PageCache ;
4
+
5
+ use Fastly \Cdn \Model \Config ;
6
+ use Magento \CacheInvalidate \Model \PurgeCache ;
7
+
8
+ /**
9
+ * Fastly CDN for Magento
10
+ *
11
+ * NOTICE OF LICENSE
12
+ *
13
+ * This source file is subject to the Fastly CDN for Magento End User License Agreement
14
+ * that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Fastly CDN to newer
19
+ * versions in the future. If you wish to customize this module for your
20
+ * needs please refer to http://www.magento.com for more information.
21
+ *
22
+ * @category Fastly
23
+ * @package Fastly_Cdn
24
+ * @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
25
+ * @license BSD, see LICENSE_FASTLY_CDN.txt
26
+ */
27
+ class PurgeCachePlugin
28
+ {
29
+ /**
30
+ * @var Config
31
+ */
32
+ protected $ config ;
33
+
34
+ /**
35
+ * PurgeCachePlugin constructor.
36
+ *
37
+ * @param Config $config
38
+ */
39
+ public function __construct (
40
+ Config $ config
41
+ ) {
42
+ $ this ->config = $ config ;
43
+ }
44
+
45
+ /**
46
+ * Prevent Magento from executing purge requests on Varnish when Fastly is enabled
47
+ *
48
+ * @param PurgeCache $subject
49
+ * @param callable $proceed
50
+ * @param array ...$args
51
+ */
52
+ public function aroundSendPurgeRequest (PurgeCache $ subject , callable $ proceed , ...$ args )
53
+ {
54
+ if ($ this ->config ->isFastlyEnabled () !== true ) {
55
+ $ proceed (...$ args );
56
+ }
57
+ }
58
+ }
Original file line number Diff line number Diff line change 27
27
<type name =" Magento\PageCache\Model\Config" >
28
28
<plugin name =" fastly_emulate_varnish_cache_type" type =" Fastly\Cdn\Model\PageCache\ConfigPlugin" />
29
29
</type >
30
+ <type name =" Magento\CacheInvalidate\Model\PurgeCache" >
31
+ <plugin name =" fastly_disable_varnish_calls" type =" Fastly\Cdn\Model\PageCache\PurgeCachePlugin" />
32
+ </type >
30
33
<type name =" Magento\Framework\Console\CommandList" >
31
34
<arguments >
32
35
<argument name =" commands" xsi : type =" array" >
You can’t perform that action at this time.
0 commit comments