Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Varnish.php
Go to the documentation of this file.
1 <?php
7 
13 class Varnish extends \Magento\Framework\App\Config\Value
14 {
18  protected $defaultValues;
19 
26  public function beforeSave()
27  {
28  $data = $this->_getDefaultValues();
29  $currentValue = $this->getValue();
30  if (!$currentValue) {
31  $replaceValue = isset($data[$this->getField()]) ? $data[$this->getField()] : false;
32  $this->setValue($replaceValue);
33  }
34  return $this;
35  }
36 
42  protected function _getDefaultValues()
43  {
44  if (!$this->defaultValues) {
45  $this->defaultValues = $this->_config->getValue('system/full_page_cache/default');
46  }
47  return $this->defaultValues;
48  }
49 
55  protected function _afterLoad()
56  {
57  $data = $this->_getDefaultValues();
58  $currentValue = $this->getValue();
59  if (!$currentValue) {
60  foreach ($data as $field => $value) {
61  if (strstr($this->getPath(), $field)) {
62  $this->setValue($value);
63  $this->save();
64  break;
65  }
66  }
67  }
68  return $this;
69  }
70 }
$value
Definition: gender.phtml:16