Development

Changeset 10227

You must first sign up to be able to contribute.

Changeset 10227

Show
Ignore:
Timestamp:
07/11/08 21:36:32 (1 year ago)
Author:
fabien
Message:

fixed cache on components

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/helper/PartialHelper.php

    r9128 r10227  
    137137  $actionName = '_'.$componentName; 
    138138 
     139  $view = new sfPartialView($context, $moduleName, $actionName, ''); 
     140  $view->setPartialVars($vars); 
     141 
     142  if ($retval = $view->getCache()) 
     143  { 
     144    return $retval; 
     145  } 
     146 
    139147  $allVars = _call_component($moduleName, $componentName, $vars); 
    140148 
     
    142150  { 
    143151    // render 
    144     $view = new sfPartialView($context, $moduleName, $actionName, ''); 
    145     $view->setPartialVars($vars); 
    146152    $view->getAttributeHolder()->add($allVars); 
    147153 
  • branches/1.1/lib/view/sfPartialView.class.php

    r9496 r10227  
    6767    } 
    6868 
    69     if (sfConfig::get('sf_cache')) 
     69    if ($retval = $this->getCache()) 
    7070    { 
    71       $viewCache = $this->context->getViewCacheManager(); 
    72       $viewCache->registerConfiguration($this->moduleName); 
    73  
    74       $cacheKey = $viewCache->computeCacheKey($this->partialVars); 
    75       if ($retval = $viewCache->getPartialCache($this->moduleName, $this->actionName, $cacheKey)) 
    76       { 
    77         return $retval; 
    78       } 
    79       else 
    80       { 
    81         $mainResponse = $this->context->getResponse(); 
    82         $responseClass = get_class($mainResponse); 
    83         $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), $mainResponse->getOptions())); 
    84       } 
     71      return $retval; 
     72    } 
     73    else if (sfConfig::get('sf_cache')) 
     74    { 
     75      $mainResponse = $this->context->getResponse(); 
     76      $responseClass = get_class($mainResponse); 
     77      $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), $mainResponse->getOptions())); 
    8578    } 
    8679 
     
    9588    if (sfConfig::get('sf_cache')) 
    9689    { 
    97       $retval = $viewCache->setPartialCache($this->moduleName, $this->actionName, $cacheKey, $retval); 
     90      $retval = $this->viewCache->setPartialCache($this->moduleName, $this->actionName, $this->cacheKey, $retval); 
    9891      $this->context->setResponse($mainResponse); 
    9992      $mainResponse->merge($response); 
     
    107100    return $retval; 
    108101  } 
     102 
     103  public function getCache() 
     104  { 
     105    if (!sfConfig::get('sf_cache')) 
     106    { 
     107      return null; 
     108    } 
     109 
     110    $this->viewCache = $this->context->getViewCacheManager(); 
     111    $this->viewCache->registerConfiguration($this->moduleName); 
     112 
     113    $this->cacheKey = $this->viewCache->computeCacheKey($this->partialVars); 
     114    if ($retval = $this->viewCache->getPartialCache($this->moduleName, $this->actionName, $this->cacheKey)) 
     115    { 
     116      return $retval; 
     117    } 
     118  } 
    109119} 
  • branches/1.2/lib/helper/PartialHelper.php

    r9128 r10227  
    137137  $actionName = '_'.$componentName; 
    138138 
     139  $view = new sfPartialView($context, $moduleName, $actionName, ''); 
     140  $view->setPartialVars($vars); 
     141 
     142  if ($retval = $view->getCache()) 
     143  { 
     144    return $retval; 
     145  } 
     146 
    139147  $allVars = _call_component($moduleName, $componentName, $vars); 
    140148 
     
    142150  { 
    143151    // render 
    144     $view = new sfPartialView($context, $moduleName, $actionName, ''); 
    145     $view->setPartialVars($vars); 
    146152    $view->getAttributeHolder()->add($allVars); 
    147153 
  • branches/1.2/lib/view/sfPartialView.class.php

    r9496 r10227  
    6767    } 
    6868 
    69     if (sfConfig::get('sf_cache')) 
     69    if ($retval = $this->getCache()) 
    7070    { 
    71       $viewCache = $this->context->getViewCacheManager(); 
    72       $viewCache->registerConfiguration($this->moduleName); 
    73  
    74       $cacheKey = $viewCache->computeCacheKey($this->partialVars); 
    75       if ($retval = $viewCache->getPartialCache($this->moduleName, $this->actionName, $cacheKey)) 
    76       { 
    77         return $retval; 
    78       } 
    79       else 
    80       { 
    81         $mainResponse = $this->context->getResponse(); 
    82         $responseClass = get_class($mainResponse); 
    83         $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), $mainResponse->getOptions())); 
    84       } 
     71      return $retval; 
     72    } 
     73    else if (sfConfig::get('sf_cache')) 
     74    { 
     75      $mainResponse = $this->context->getResponse(); 
     76      $responseClass = get_class($mainResponse); 
     77      $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), $mainResponse->getOptions())); 
    8578    } 
    8679 
     
    9588    if (sfConfig::get('sf_cache')) 
    9689    { 
    97       $retval = $viewCache->setPartialCache($this->moduleName, $this->actionName, $cacheKey, $retval); 
     90      $retval = $this->viewCache->setPartialCache($this->moduleName, $this->actionName, $this->cacheKey, $retval); 
    9891      $this->context->setResponse($mainResponse); 
    9992      $mainResponse->merge($response); 
     
    107100    return $retval; 
    108101  } 
     102 
     103  public function getCache() 
     104  { 
     105    if (!sfConfig::get('sf_cache')) 
     106    { 
     107      return null; 
     108    } 
     109 
     110    $this->viewCache = $this->context->getViewCacheManager(); 
     111    $this->viewCache->registerConfiguration($this->moduleName); 
     112 
     113    $this->cacheKey = $this->viewCache->computeCacheKey($this->partialVars); 
     114    if ($retval = $this->viewCache->getPartialCache($this->moduleName, $this->actionName, $this->cacheKey)) 
     115    { 
     116      return $retval; 
     117    } 
     118  } 
    109119} 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.