Development

/branches/1.1/lib/view/sfViewCacheManager.class.php

You must first sign up to be able to contribute.

root/branches/1.1/lib/view/sfViewCacheManager.class.php

Revision 9408, 23.7 kB (checked in by fabien, 5 years ago)

fixed sfViewCacheManager when using sf_cache_namespace_callable setting

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * Cache class to cache the HTML results for actions and templates.
13  *
14  * This class uses a sfCache instance implementation to store cache.
15  *
16  * To disable all caching, you can set the [sf_cache] constant to false.
17  *
18  * @package    symfony
19  * @subpackage view
20  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
21  * @version    SVN: $Id$
22  */
23 class sfViewCacheManager
24 {
25   protected
26     $cache       = null,
27     $cacheConfig = array(),
28     $context     = null,
29     $dispatcher  = null,
30     $controller  = null,
31     $routing     = null,
32     $loaded      = array();
33
34   /**
35    * Class constructor.
36    *
37    * @see initialize()
38    */
39   public function __construct($context, sfCache $cache)
40   {
41     $this->initialize($context, $cache);
42   }
43
44   /**
45    * Initializes the cache manager.
46    *
47    * @param sfContext $context  Current application context
48    * @param sfCache   $cache    An sfCache instance
49    */
50   public function initialize($context, sfCache $cache)
51   {
52     $this->context    = $context;
53     $this->dispatcher = $context->getEventDispatcher();
54     $this->controller = $context->getController();
55
56     // empty configuration
57     $this->cacheConfig = array();
58
59     // cache instance
60     $this->cache = $cache;
61
62     // routing instance
63     $this->routing = $context->getRouting();
64   }
65
66   /**
67    * Retrieves the current cache context.
68    *
69    * @return sfContext The sfContext instance
70    */
71   public function getContext()
72   {
73     return $this->context;
74   }
75
76   /**
77    * Retrieves the current cache object.
78    *
79    * @return sfCache The current cache object
80    */
81   public function getCache()
82   {
83     return $this->cache;
84   }
85
86   /**
87    * Generates a unique cache key for an internal URI.
88    * This cache key can be used by any of the cache engines as a unique identifier to a cached resource
89    *
90    * Basically, the cache key generated for the following internal URI:
91    *   module/action?key1=value1&key2=value2
92    * Looks like:
93    *   /localhost/all/module/action/key1/value1/key2/value2
94    *
95    * @param  string $internalUri       The internal unified resource identifier
96    *                                   Accepts rules formatted like 'module/action?key1=value1&key2=value2'
97    *                                   Does not accept rules starting with a route name, except for '@sf_cache_partial'
98    * @param  string $hostName          The host name
99    *                                   Optional - defaults to the current host name bu default
100    * @param  string $vary              The vary headers, separated by |, or "all" for all vary headers
101    *                                   Defaults to 'all'
102    * @param  string $contextualPrefix  The contextual prefix for contextual partials.
103    *                                   Defaults to 'currentModule/currentAction/currentPAram1/currentvalue1'
104    *                                   Used only by the sfViewCacheManager::remove() method
105    *
106    * @return string The cache key
107    *                If some of the parameters contained wildcards (* or **), the generated key will also have wildcards
108    */
109   public function generateCacheKey($internalUri, $hostName = '', $vary = '', $contextualPrefix = '')
110   {
111     if ($callable = sfConfig::get('sf_cache_namespace_callable'))
112     {
113       if (!is_callable($callable))
114       {
115         throw new sfException(sprintf('"%s" cannot be called as a function.', var_export($callable, true)));
116       }
117
118       return call_user_func($callable, $internalUri, $hostName, $vary, $contextualPrefix);
119     }
120
121     if (strpos($internalUri, '@') === 0 && strpos($internalUri, '@sf_cache_partial') === false)
122     {
123       throw new sfException('A cache key cannot be generated for an internal URI using the @rule syntax');
124     }
125
126     $cacheKey = '';
127
128     if ($this->isContextual($internalUri))
129     {
130       // Contextual partial
131       if (!$contextualPrefix)
132       {
133         list($route_name, $params) = $this->controller->convertUrlStringToParameters($this->routing->getCurrentInternalUri());
134         $cacheKey = $this->convertParametersToKey($params);
135       }
136       else
137       {
138         $cacheKey = $contextualPrefix;
139       }
140       list($route_name, $params) = $this->controller->convertUrlStringToParameters($internalUri);
141       $cacheKey .= sprintf('/%s/%s/%s', $params['module'], $params['action'], $params['sf_cache_key']);
142     }
143     else
144     {
145       // Regular action or non-contextual partial
146       list($route_name, $params) = $this->controller->convertUrlStringToParameters($internalUri);
147       if ($route_name == 'sf_cache_partial')
148       {
149         $cacheKey = 'sf_cache_partial/';
150       }
151
152       $cacheKey .= $this->convertParametersToKey($params);
153     }
154
155     // prefix with vary headers
156     if (!$vary)
157     {
158       $varyHeaders = $this->getVary($internalUri);
159       if ($varyHeaders)
160       {
161         sort($varyHeaders);
162         $request = $this->context->getRequest();
163         $vary = '';
164
165         foreach ($varyHeaders as $header)
166         {
167           $vary .= $request->getHttpHeader($header).'|';
168         }
169
170         $vary = $vary;
171       }
172       else
173       {
174         $vary = 'all';
175       }
176     }
177
178     // prefix with hostname
179     if (!$hostName)
180     {
181       $request = $this->context->getRequest();
182       $hostName = $request->getHost();
183       $hostName = preg_replace('/[^a-z0-9]/i', '_', $hostName);
184       $hostName = strtolower(preg_replace('/_+/', '_', $hostName));
185     }
186
187     $cacheKey = sprintf('/%s/%s/%s', $hostName, $vary, $cacheKey);
188
189     // replace multiple /
190     $cacheKey = preg_replace('#/+#', '/', $cacheKey);
191
192     return $cacheKey;
193   }
194
195   /**
196    * Transforms an associative array of parameters from an URI into a unique key
197    *
198    * @param  array $params  Associative array of parameters from the URI (including, at least, module and action)
199    *
200    * @return string Unique key
201    */
202   protected function convertParametersToKey($params)
203   {
204     if(!isset($params['module']) || !isset($params['action']))
205     {
206       throw new sfException('A cache key must contain both a module and an action parameter');
207     }
208     $module = $params['module'];
209     unset($params['module']);
210     $action = $params['action'];
211     unset($params['action']);
212     ksort($params);
213     $cacheKey = sprintf('%s/%s', $module, $action);
214     foreach ($params as $key => $value)
215     {
216       $cacheKey .= sprintf('/%s/%s', $key, $value);
217     }
218
219     return $cacheKey;
220   }
221
222   /**
223    * Adds a cache to the manager.
224    *
225    * @param string $moduleName  Module name
226    * @param string $actionName  Action name
227    * @param array  $options     Options for the cache
228    */
229   public function addCache($moduleName, $actionName, $options = array())
230   {
231     // normalize vary headers
232     if (isset($options['vary']))
233     {
234       foreach ($options['vary'] as $key => $name)
235       {
236         $options['vary'][$key] = strtr(strtolower($name), '_', '-');
237       }
238     }
239
240     $options['lifeTime'] = isset($options['lifeTime']) ? $options['lifeTime'] : 0;
241     if (!isset($this->cacheConfig[$moduleName]))
242     {
243       $this->cacheConfig[$moduleName] = array();
244     }
245     $this->cacheConfig[$moduleName][$actionName] = array(
246       'withLayout'     => isset($options['withLayout']) ? $options['withLayout'] : false,
247       'lifeTime'       => $options['lifeTime'],
248       'clientLifeTime' => isset($options['clientLifeTime']) ? $options['clientLifeTime'] : $options['lifeTime'],
249       'contextual'     => isset($options['contextual']) ? $options['contextual'] : false,
250       'vary'           => isset($options['vary']) ? $options['vary'] : array(),
251     );
252   }
253
254   /**
255    * Registers configuration options for the cache.
256    *
257    * @param string $moduleName  Module name
258    */
259   public function registerConfiguration($moduleName)
260   {
261     if (!isset($this->loaded[$moduleName]))
262     {
263       require($this->context->getConfigCache()->checkConfig('modules/'.$moduleName.'/config/cache.yml'));
264       $this->loaded[$moduleName] = true;
265     }
266   }
267
268   /**
269    * Retrieves the layout from the cache option list.
270    *
271    * @param  string $internalUri  Internal uniform resource identifier
272    *
273    * @return bool true, if have layout otherwise false
274    */
275   public function withLayout($internalUri)
276   {
277     return $this->getCacheConfig($internalUri, 'withLayout', false);
278   }
279
280   /**
281    * Retrieves lifetime from the cache option list.
282    *
283    * @param  string $internalUri  Internal uniform resource identifier
284    *
285    * @return int LifeTime
286    */
287   public function getLifeTime($internalUri)
288   {
289     return $this->getCacheConfig($internalUri, 'lifeTime', 0);
290   }
291
292   /**
293    * Retrieves client lifetime from the cache option list
294    *
295    * @param  string $internalUri  Internal uniform resource identifier
296    *
297    * @return int Client lifetime
298    */
299   public function getClientLifeTime($internalUri)
300   {
301     return $this->getCacheConfig($internalUri, 'clientLifeTime', 0);
302   }
303
304   /**
305    * Retrieves contextual option from the cache option list.
306    *
307    * @param  string $internalUri  Internal uniform resource identifier
308    *
309    * @return boolean true, if is contextual otherwise false
310    */
311   public function isContextual($internalUri)
312   {
313     return $this->getCacheConfig($internalUri, 'contextual', false);
314   }
315
316   /**
317    * Retrieves vary option from the cache option list.
318    *
319    * @param  string $internalUri  Internal uniform resource identifier
320    *
321    * @return array Vary options for the cache
322    */
323   public function getVary($internalUri)
324   {
325     return $this->getCacheConfig($internalUri, 'vary', array());
326   }
327
328   /**
329    * Gets a config option from the cache.
330    *
331    * @param string $internalUri   Internal uniform resource identifier
332    * @param string $key           Option name
333    * @param string $defaultValue  Default value of the option
334    *
335    * @return mixed Value of the option
336    */
337   protected function getCacheConfig($internalUri, $key, $defaultValue = null)
338   {
339     list($route_name, $params) = $this->controller->convertUrlStringToParameters($internalUri);
340
341     $value = $defaultValue;
342     if (isset($this->cacheConfig[$params['module']][$params['action']][$key]))
343     {
344       $value = $this->cacheConfig[$params['module']][$params['action']][$key];
345     }
346     else if (isset($this->cacheConfig[$params['module']]['DEFAULT'][$key]))
347     {
348       $value = $this->cacheConfig[$params['module']]['DEFAULT'][$key];
349     }
350
351     return $value;
352   }
353
354   /**
355    * Returns true if the current content is cacheable.
356    *
357    * @param  string $internalUri  Internal uniform resource identifier
358    *
359    * @return bool true, if the content is cacheable otherwise false
360    */
361   public function isCacheable($internalUri)
362   {
363     if (count($_GET) || count($_POST))
364     {
365       return false;
366     }
367
368     list($route_name, $params) = $this->controller->convertUrlStringToParameters($internalUri);
369
370     if (isset($this->cacheConfig[$params['module']][$params['action']]))
371     {
372       return ($this->cacheConfig[$params['module']][$params['action']]['lifeTime'] > 0);
373     }
374     else if (isset($this->cacheConfig[$params['module']]['DEFAULT']))
375     {
376       return ($this->cacheConfig[$params['module']]['DEFAULT']['lifeTime'] > 0);
377     }
378
379     return false;
380   }
381
382   /**
383    * Retrieves content in the cache.
384    *
385    * @param  string $internalUri  Internal uniform resource identifier
386    *
387    * @return string The content in the cache
388    */
389   public function get($internalUri)
390   {
391     // no cache or no cache set for this action
392     if (!$this->isCacheable($internalUri) || $this->ignore())
393     {
394       return null;
395     }
396
397     $retval = $this->cache->get($this->generateCacheKey($internalUri));
398
399     if (sfConfig::get('sf_logging_enabled'))
400     {
401       $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Cache for "%s" %s', $internalUri, $retval !== null ? 'exists' : 'does not exist'))));
402     }
403
404     return $retval;
405   }
406
407   /**
408    * Returns true if there is a cache.
409    *
410    * @param  string $internalUri  Internal uniform resource identifier
411    *
412    * @return bool true, if there is a cache otherwise false
413    */
414   public function has($internalUri)
415   {
416     if (!$this->isCacheable($internalUri) || $this->ignore())
417     {
418       return null;
419     }
420
421     return $this->cache->has($this->generateCacheKey($internalUri));
422   }
423
424   /**
425    * Ignores the cache functionality.
426    *
427    * @return bool true, if the cache is ignore otherwise false
428    */
429   protected function ignore()
430   {
431     // ignore cache parameter? (only available in debug mode)
432     if (sfConfig::get('sf_debug') && $this->context->getRequest()->getAttribute('_sf_ignore_cache'))
433     {
434       if (sfConfig::get('sf_logging_enabled'))
435       {
436         $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Discard cache')));
437       }
438
439       return true;
440     }
441
442     return false;
443   }
444
445   /**
446    * Sets the cache content.
447    *
448    * @param  string $data         Data to put in the cache
449    * @param  string $internalUri  Internal uniform resource identifier
450    *
451    * @return boolean true, if the data get set successfully otherwise false
452    */
453   public function set($data, $internalUri)
454   {
455     if (!$this->isCacheable($internalUri))
456     {
457       return false;
458     }
459
460     try
461     {
462       $ret = $this->cache->set($this->generateCacheKey($internalUri), $data, $this->getLifeTime($internalUri));
463     }
464     catch (Exception $e)
465     {
466       return false;
467     }
468
469     if (sfConfig::get('sf_logging_enabled'))
470     {
471       $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Save cache for "%s"', $internalUri))));
472     }
473
474     return true;
475   }
476
477   /**
478    * Removes the content in the cache.
479    *
480    * @param  string $internalUri       Internal uniform resource identifier
481    * @param  string $hostName          The host name
482    * @param  string $vary              The vary headers, separated by |, or "all" for all vary headers
483    * @param  string $contextualPrefix  The removal prefix for contextual partials. Deauls to '**' (all actions, all params)
484    *
485    * @return bool true, if the remove happened, false otherwise
486    */
487   public function remove($internalUri, $hostName = '', $vary = '', $contextualPrefix = '**')
488   {
489     if (sfConfig::get('sf_logging_enabled'))
490     {
491       $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Remove cache for "%s"', $internalUri))));
492     }
493
494     $cacheKey = $this->generateCacheKey($internalUri, $hostName, $vary, $contextualPrefix);
495
496     if(strpos($cacheKey, '*'))
497     {
498       return $this->cache->removePattern($cacheKey);
499     }
500     elseif ($this->cache->has($cacheKey))
501     {
502       return $this->cache->remove($cacheKey);
503     }
504   }
505
506   /**
507    * Retrieves the last modified time.
508    *
509    * @param  string $internalUri  Internal uniform resource identifier
510    *
511    * @return int    The last modified datetime
512    */
513   public function getLastModified($internalUri)
514   {
515     if (!$this->isCacheable($internalUri))
516     {
517       return 0;
518     }
519
520     return $this->cache->getLastModified($this->generateCacheKey($internalUri));
521   }
522
523   /**
524    * Retrieves the timeout.
525    *
526    * @param  string $internalUri  Internal uniform resource identifier
527    *
528    * @return int    The timeout datetime
529    */
530   public function getTimeout($internalUri)
531   {
532     if (!$this->isCacheable($internalUri))
533     {
534       return 0;
535     }
536
537     return $this->cache->getTimeout($this->generateCacheKey($internalUri));
538   }
539
540   /**
541    * Starts the fragment cache.
542    *
543    * @param  string $name            Unique fragment name
544    * @param  string $lifeTime        Life time for the cache
545    * @param  string $clientLifeTime  Client life time for the cache
546    * @param  array  $vary            Vary options for the cache
547    *
548    * @return bool true, if success otherwise false
549    */
550   public function start($name, $lifeTime, $clientLifeTime = null, $vary = array())
551   {
552     $internalUri = $this->routing->getCurrentInternalUri();
553
554     if (!$clientLifeTime)
555     {
556       $clientLifeTime = $lifeTime;
557     }
558
559     // add cache config to cache manager
560     list($route_name, $params) = $this->controller->convertUrlStringToParameters($internalUri);
561     $this->addCache($params['module'], $params['action'], array('withLayout' => false, 'lifeTime' => $lifeTime, 'clientLifeTime' => $clientLifeTime, 'vary' => $vary));
562
563     // get data from cache if available
564     $data = $this->get($internalUri.(strpos($internalUri, '?') ? '&' : '?').'_sf_cache_key='.$name);
565     if ($data !== null)
566     {
567       return $data;
568     }
569     else
570     {
571       ob_start();
572       ob_implicit_flush(0);
573
574       return null;
575     }
576   }
577
578   /**
579    * Stops the fragment cache.
580    *
581    * @param  string $name Unique fragment name
582    *
583    * @return bool true, if success otherwise false
584    */
585   public function stop($name)
586   {
587     $data = ob_get_clean();
588
589     // save content to cache
590     $internalUri = $this->routing->getCurrentInternalUri();
591     try
592     {
593       $this->set($data, $internalUri.(strpos($internalUri, '?') ? '&' : '?').'_sf_cache_key='.$name);
594     }
595     catch (Exception $e)
596     {
597     }
598
599     return $data;
600   }
601
602   /**
603    * Computes the cache key based on the passed parameters.
604    *
605    * @param array $parameters  An array of parameters
606    */
607   public function computeCacheKey(array $parameters)
608   {
609     return isset($parameters['sf_cache_key']) ? $parameters['sf_cache_key'] : md5(serialize($parameters));
610   }
611
612   /**
613    * Computes a partial internal URI.
614    *
615    * @param  string $module    The module name
616    * @param  string $action    The action name
617    * @param  string $cacheKey  The cache key
618    *
619    * @return string The internal URI
620    */
621   public function getPartialUri($module, $action, $cacheKey)
622   {
623     return sprintf('@sf_cache_partial?module=%s&action=%s&sf_cache_key=%s', $module, $action, $cacheKey);
624   }
625
626   /**
627    * Returns whether a partial template is in the cache.
628    *
629    * @param  string $module    The module name
630    * @param  string $action    The action name
631    * @param  string $cacheKey  The cache key
632    *
633    * @return bool true if a partial is in the cache, false otherwise
634    */
635   public function hasPartialCache($module, $action, $cacheKey)
636   {
637     return $this->has($this->getPartialUri($module, $action, $cacheKey));
638   }
639
640   /**
641    * Gets a partial template from the cache.
642    *
643    * @param  string $module    The module name
644    * @param  string $action    The action name
645    * @param  string $cacheKey  The cache key
646    *
647    * @return string The cache content
648    */
649   public function getPartialCache($module, $action, $cacheKey)
650   {
651     $uri = $this->getPartialUri($module, $action, $cacheKey);
652
653     if (!$this->isCacheable($uri))
654     {
655       return null;
656     }
657
658     // retrieve content from cache
659     $cache = $this->get($uri);
660
661     if (is_null($cache))
662     {
663       return null;
664     }
665
666     $cache = unserialize($cache);
667     $content = $cache['content'];
668     $this->context->getResponse()->merge($cache['response']);
669
670     if (sfConfig::get('sf_web_debug'))
671     {
672       $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $content)->getReturnValue();
673     }
674
675     return $content;
676   }
677
678   /**
679    * Sets an action template in the cache.
680    *
681    * @param  string $module    The module name
682    * @param  string $action    The action name
683    * @param  string $cacheKey  The cache key
684    * @param  string $content   The content to cache
685    *
686    * @return string The cached content
687    */
688   public function setPartialCache($module, $action, $cacheKey, $content)
689   {
690     $uri = $this->getPartialUri($module, $action, $cacheKey);
691     if (!$this->isCacheable($uri))
692     {
693       return $content;
694     }
695
696     $saved = $this->set(serialize(array('content' => $content, 'response' => $this->context->getResponse())), $uri);
697
698     if ($saved && sfConfig::get('sf_web_debug'))
699     {
700       $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $content)->getReturnValue();
701     }
702
703     return $content;
704   }
705
706   /**
707    * Returns whether an action template is in the cache.
708    *
709    * @param  string  $uri  The internal URI
710    *
711    * @return bool true if an action is in the cache, false otherwise
712    */
713   public function hasActionCache($uri)
714   {
715     return $this->has($uri) && !$this->withLayout($uri);
716   }
717
718   /**
719    * Gets an action template from the cache.
720    *
721    * @param  string $uri  The internal URI
722    *
723    * @return array  An array composed of the cached content and the view attribute holder
724    */
725   public function getActionCache($uri)
726   {
727     if (!$this->isCacheable($uri) || $this->withLayout($uri))
728     {
729       return null;
730     }
731
732     // retrieve content from cache
733     $cache = $this->get($uri);
734
735     if (is_null($cache))
736     {
737       return null;
738     }
739
740     $cache = unserialize($cache);
741     $content = $cache['content'];
742     $cache['response']->setEventDispatcher($this->dispatcher);
743     $this->context->getResponse()->copyProperties($cache['response']);
744
745     if (sfConfig::get('sf_web_debug'))
746     {
747       $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $content)->getReturnValue();
748     }
749
750     return array($content, $cache['decoratorTemplate']);
751   }
752
753   /**
754    * Sets an action template in the cache.
755    *
756    * @param  string $uri                The internal URI
757    * @param  string $content            The content to cache
758    * @param  string $decoratorTemplate  The view attribute holder to cache
759    *
760    * @return string The cached content
761    */
762   public function setActionCache($uri, $content, $decoratorTemplate)
763   {
764     if (!$this->isCacheable($uri) || $this->withLayout($uri))
765     {
766       return $content;
767     }
768
769     $saved = $this->set(serialize(array('content' => $content, 'decoratorTemplate' => $decoratorTemplate, 'response' => $this->context->getResponse())), $uri);
770
771     if ($saved && sfConfig::get('sf_web_debug'))
772     {
773       $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $content)->getReturnValue();
774     }
775
776     return $content;
777   }
778
779   /**
780    * Sets a page in the cache.
781    *
782    * @param string $uri  The internal URI
783    */
784   public function setPageCache($uri)
785   {
786     if (sfView::RENDER_CLIENT != $this->controller->getRenderMode())
787     {
788       return;
789     }
790
791     // save content in cache
792     $saved = $this->set(serialize($this->context->getResponse()), $uri);
793
794     if ($saved && sfConfig::get('sf_web_debug'))
795     {
796       $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $this->context->getResponse()->getContent())->getReturnValue();
797
798       $this->context->getResponse()->setContent($content);
799     }
800   }
801
802   /**
803    * Gets a page from the cache.
804    *
805    * @param  string $uri  The internal URI
806    *
807    * @return string The cached page
808    */
809   public function getPageCache($uri)
810   {
811     $retval = $this->get($uri);
812
813     if (is_null($retval))
814     {
815       return false;
816     }
817
818     $cachedResponse = unserialize($retval);
819     $cachedResponse->setEventDispatcher($this->dispatcher);
820
821     if (sfView::RENDER_VAR == $this->controller->getRenderMode())
822     {
823       $this->controller->getActionStack()->getLastEntry()->setPresentation($cachedResponse->getContent());
824       $this->response->setContent('');
825     }
826     else
827     {
828       $this->context->setResponse($cachedResponse);
829
830       if (sfConfig::get('sf_web_debug'))
831       {
832         $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $this->context->getResponse()->getContent())->getReturnValue();
833
834         $this->context->getResponse()->setContent($content);
835       }
836     }
837
838     return true;
839   }
840 }
841
Note: See TracBrowser for help on using the browser.