app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php
public function adminSystemConfigChangedSection($eventObject) {
        if (Mage::helper('turpentine/varnish')->getVarnishEnabled() &&
                Mage::helper('turpentine/data')->getAutoApplyOnSave()) {
            $result = Mage::getModel('turpentine/varnish_admin')->applyConfig();
            $session = Mage::getSingleton('core/session');
            $helper = Mage::helper('turpentine');
            foreach ($result as $name => $value) {
                if ($value === true) {
                    $session->addSuccess($helper
                        ->__('VCL successfully applied to: '.$name));
                } else {
                    $session->addError($helper
                        ->__(sprintf('Failed to apply the VCL to %s: %s',
                            $name, $value)));
                }
            }
            $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator();
            if (is_null($cfgr)) {
                $session->addError($helper
                    ->__('Failed to load configurator'));
            } else {
                $result = $cfgr->save($cfgr->generate($helper->shouldStripVclWhitespace('save')));
                if ($result[0]) {
                    $session->addSuccess($helper
                        ->__('The VCL file has been saved.'));
                } else {
                    $session->addError($helper
                        ->__('Failed to save the VCL file: '.$result[1]['message']));
                }
            }
        }
    }
public function adminSystemConfigChangedSection($eventObject) {
        if (Mage::helper('turpentine/varnish')->getVarnishEnabled() &&
                Mage::helper('turpentine/data')->getAutoApplyOnSave()) {
            $result = Mage::getModel('turpentine/varnish_admin')->applyConfig();
            $session = Mage::getSingleton('core/session');
            $helper = Mage::helper('turpentine');
            foreach ($result as $name => $value) {
                if ($value === true) {
                    $session->addSuccess($helper
                        ->__('VCL successfully applied to: '.$name));
                } else {
                    $session->addError($helper
                        ->__(sprintf('Failed to apply the VCL to %s: %s',
                            $name, $value)));
                }
            }
            $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator();
            if (is_null($cfgr)) {
                $session->addError($helper
                    ->__('Failed to load configurator'));
            } else {
                $result = $cfgr->save($cfgr->generate($helper->shouldStripVclWhitespace('save')));
                if ($result[0]) {
                    $session->addSuccess($helper
                        ->__('The VCL file has been saved.'));
                } else {
                    $session->addError($helper
                        ->__('Failed to save the VCL file: '.$result[1]['message']));
                }
            }
        }
    }
public function adminSystemConfigChangedSection ( $ eventObject ) { if ( Mage :: helper ( 'turpentine/varnish' ) -> getVarnishEnabled ( ) && Mage :: helper ( 'turpentine/data' ) -> getAutoApplyOnSave ( ) ) { $ result = Mage :: getModel ( 'turpentine/varnish_admin' ) -> applyConfig ( ) ; $ session = Mage :: getSingleton ( 'core/session' ) ; $ helper = Mage :: helper ( 'turpentine' ) ; foreach ( $ result as $ name => $ value ) { if ( $ value === true ) { $ session -> addSuccess ( $ helper -> __ ( 'VCL successfully applied to: ' . $ name ) ) ; } else { $ session -> addError ( $ helper -> __ ( sprintf ( 'Failed to apply the VCL to %s: %s' , $ name , $ value ) ) ) ; } } $ cfgr = Mage :: getModel ( 'turpentine/varnish_admin' ) -> getConfigurator ( ) ; if ( is_null ( $ cfgr ) ) { $ session -> addError ( $ helper -> __ ( 'Failed to load configurator' ) ) ; } else { $ result = $ cfgr -> save ( $ cfgr -> generate ( $ helper -> shouldStripVclWhitespace ( 'save' ) ) ) ; if ( $ result [ 0 ] ) { $ session -> addSuccess ( $ helper -> __ ( 'The VCL file has been saved.' ) ) ; } else { $ session -> addError ( $ helper -> __ ( 'Failed to save the VCL file: ' . $ result [ 1 ] [ 'message' ] ) ) ; } } } }
Re-apply and save Varnish configuration on config change

@param  mixed $eventObject
@return null
Re - apply and save Varnish configuration on config change