array('type' => 'boolean', 'default' => false), 'ipAddressMaskLength' => array('type' => 'integer', 'default' => 2), 'doNotTrackEnabled' => array('type' => 'boolean', 'default' => true), 'ipAnonymizerEnabled' => array('type' => 'boolean', 'default' => true), 'forceCookielessTracking' => array('type' => 'boolean', 'default' => false), 'anonymizeUserId' => array('type' => 'boolean', 'default' => false), 'anonymizeOrderId' => array('type' => 'boolean', 'default' => false), 'anonymizeReferrer' => array('type' => 'string', 'default' => ''), ); public function __set($name, $value) { if (!array_key_exists($name, $this->properties)) { throw new \Exception(sprintf('Property %s does not exist', $name)); } $this->set($name, $value, $this->properties[$name]); } public function __get($name) { if (!array_key_exists($name, $this->properties)) { throw new \Exception(sprintf('Property %s does not exist', $name)); } return $this->getFromTrackerCache($name, $this->properties[$name]); } private function prefix($optionName) { return 'PrivacyManager.' . $optionName; } private function getFromTrackerCache($name, $config) { $name = $this->prefix($name); $cache = Cache::getCacheGeneral(); if (array_key_exists($name, $cache)) { $value = $cache[$name]; settype($value, $config['type']); return $value; } return $config['default']; } private function getFromOption($name, $config) { $name = $this->prefix($name); $value = Option::get($name); if (false !== $value) { settype($value, $config['type']); } else { $value = $config['default']; } return $value; } private function set($name, $value, $config) { if ('boolean' == $config['type']) { $value = $value ? '1' : '0'; } else { settype($value, $config['type']); } Option::set($this->prefix($name), $value); Cache::clearCacheGeneral(); } public function setTrackerCacheGeneral($cacheContent) { foreach ($this->properties as $name => $config) { $cacheContent[$this->prefix($name)] = $this->getFromOption($name, $config); } return $cacheContent; } }