public function preUpdate($eventArgs) { global $_CONFIG, $_ARRAYLANG; try { $objSetting = $eventArgs->getEntity(); $value = $objSetting->getValue(); switch ($objSetting->getName()) { case 'timezone': if (!in_array($value, timezone_identifiers_list())) { \Message::add($_ARRAYLANG['TXT_CORE_TIMEZONE_INVALID'], \Message::CLASS_ERROR); throw new YamlSettingEventListenerException($_ARRAYLANG['TXT_CORE_TIMEZONE_INVALID']); } break; case 'domainUrl': $arrMatch = array(); if (preg_match('#^https?://(.*)$#', $value, $arrMatch)) { $value = $arrMatch[1]; } $value = htmlspecialchars($value, ENT_QUOTES, CONTREXX_CHARSET); $objSetting->setValue($value); break; case 'forceProtocolFrontend': if ($_CONFIG['forceProtocolFrontend'] != $value) { if (!\Cx\Core\Config\Controller\Config::checkAccessibility($value)) { $value = 'none'; } $objSetting->setValue($value); } break; case 'forceProtocolBackend': if ($_CONFIG['forceProtocolBackend'] != $value) { if (!\Cx\Core\Config\Controller\Config::checkAccessibility($value)) { $value = 'none'; } $objSetting->setValue($value); } break; case 'forceDomainUrl': $useHttps = $_CONFIG['forceProtocolBackend'] == 'https'; $protocol = 'http'; if ($useHttps == 'https') { $protocol = 'https'; } $value = \Cx\Core\Config\Controller\Config::checkAccessibility($protocol) ? $value : 'off'; $objSetting->setValue($value); break; } } catch (YamlSettingEventListenerException $e) { \DBG::msg($e->getMessage()); } }
public function preUpdate($eventArgs) { global $_CONFIG, $_ARRAYLANG; try { $objSetting = $eventArgs->getEntity(); $value = $objSetting->getValue(); switch ($objSetting->getName()) { case 'timezone': if (!in_array($value, timezone_identifiers_list())) { \Message::add($_ARRAYLANG['TXT_CORE_TIMEZONE_INVALID'], \Message::CLASS_ERROR); throw new YamlSettingEventListenerException($_ARRAYLANG['TXT_CORE_TIMEZONE_INVALID']); } break; case 'domainUrl': $arrMatch = array(); if (preg_match('#^https?://(.*)$#', $value, $arrMatch)) { $value = $arrMatch[1]; } $value = htmlspecialchars($value, ENT_QUOTES, CONTREXX_CHARSET); $objSetting->setValue($value); $this->getComponent('Cache')->deleteNonPagePageCache(); break; case 'forceProtocolFrontend': if ($_CONFIG['forceProtocolFrontend'] != $value) { if (!\Cx\Core\Config\Controller\Config::checkAccessibility($value)) { $value = 'none'; } $objSetting->setValue($value); } $this->getComponent('Cache')->deleteNonPagePageCache(); break; case 'forceProtocolBackend': if ($_CONFIG['forceProtocolBackend'] != $value) { if (!\Cx\Core\Config\Controller\Config::checkAccessibility($value)) { $value = 'none'; } $objSetting->setValue($value); } break; case 'forceDomainUrl': $useHttps = $_CONFIG['forceProtocolBackend'] == 'https'; $protocol = 'http'; if ($useHttps == 'https') { $protocol = 'https'; } $value = \Cx\Core\Config\Controller\Config::checkAccessibility($protocol) ? $value : 'off'; $objSetting->setValue($value); $this->getComponent('Cache')->deleteNonPagePageCache(); break; case 'cacheReverseProxy': case 'cacheProxyCacheConfig': if ($value != $_CONFIG[$objSetting->getName()]) { // drop reverse proxy cache \Cx\Core\Core\Controller\Cx::instanciate()->getComponent('Cache')->clearReverseProxyCache('*'); } break; case 'cacheSsiOutput': case 'cacheSsiType': case 'cacheSsiProcessorConfig': if ($value != $_CONFIG[$objSetting->getName()]) { // drop esi/ssi cache \Cx\Core\Core\Controller\Cx::instanciate()->getComponent('Cache')->clearSsiCache(); } break; } } catch (YamlSettingEventListenerException $e) { \DBG::msg($e->getMessage()); } }