/** * Register the custom PHP ESI parser * * @return void */ public function enableEsi() { $options = $this->getOptions(); if (isset($options['headerName'])) { Glitch_View_Helper_Esi::setHeader($options['headerName'], 1); } // Ensure the front controller is initialized $this->_bootstrap->bootstrap('FrontController'); $front = $this->_bootstrap->getResource('FrontController'); if (isset($options['phpParser']) && true === (bool) $options['phpParser']) { // Get the cache using the config settings as input $this->_bootstrap->bootstrap('CacheManager'); $manager = $this->_bootstrap->getResource('CacheManager'); if ($manager->hasCache('esi')) { $cache = $manager->getCache('esi'); Glitch_Controller_Plugin_EsiParser::setCache($cache); } // push the profiler on the plugin stack to time the dispatch process $front->registerPlugin(new Glitch_Controller_Plugin_EsiParser()); } }
/** * Create an ESI tag for a given SRC. * * @param string $uri * @return string */ public function esi($uri) { // If the ESI headers have not been sent yet do it now if (false === self::$_varnishHeaderSent) { $response = Zend_Controller_Front::getInstance()->getResponse(); $response->setHeader(self::$_varnishHeaderName, self::$_varnishHeaderValue); self::$_varnishHeaderSent = true; } return '<esi:include src="' . $uri . '"/>'; }