Skip to content

Commit 874e85b

Browse files
committed
fix Fastly const value ti int value #466
1 parent a787f86 commit 874e85b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Diff for: Model/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Config extends \Magento\PageCache\Model\Config
4545
/**
4646
* Cache types
4747
*/
48-
const FASTLY = 'fastly';
48+
const FASTLY = 42;
4949

5050
/**
5151
* Magento module prefix used for naming vcl snippets, condition and request

Diff for: Model/PageCache/ConfigPlugin.php

+30
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
1919
* @license BSD, see LICENSE_FASTLY_CDN.txt
2020
*/
21+
2122
namespace Fastly\Cdn\Model\PageCache;
2223

2324
use \Magento\PageCache\Model\Config;
@@ -36,6 +37,18 @@
3637
*/
3738
class ConfigPlugin
3839
{
40+
protected $_scopeConfig;
41+
42+
/**
43+
* ConfigPlugin constructor.
44+
*
45+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
46+
*/
47+
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
48+
{
49+
$this->_scopeConfig = $scopeConfig;
50+
}
51+
3952
/**
4053
* Return cache type "Varnish" if Fastly is configured.
4154
*
@@ -53,4 +66,21 @@ public function afterGetType(Config $config, $result)
5366
}
5467
return $result;
5568
}
69+
70+
/**
71+
* Change return value from string to int, 'fastly' is old value
72+
*
73+
* @param Config $config
74+
* @param callable $proceed
75+
* @return string
76+
*/
77+
public function aroundGetType(Config $config, callable $proceed)
78+
{
79+
if ($this->_scopeConfig->getValue(Config::XML_PAGECACHE_TYPE) === 'fastly') {
80+
$result = \Fastly\Cdn\Model\Config::FASTLY;
81+
} else {
82+
$result = $proceed();
83+
}
84+
return $result;
85+
}
5686
}

0 commit comments

Comments
 (0)