Changeset 7726
- Timestamp:
- 03/03/08 15:16:01 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php
r7725 r7726 110 110 $actionName = '_'.$componentName; 111 111 112 // check cache113 if ($cacheManager = $context->getViewCacheManager())114 {115 $cacheManager->registerConfiguration($moduleName);116 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $cacheManager->computeCacheKey($vars)))117 {118 return $retval;119 }120 else121 {122 $mainResponse = $context->getResponse();123 $responseClass = get_class($mainResponse);124 $context->setResponse($response = new $responseClass($context->getEventDispatcher(), $mainResponse->getOptions()));125 }126 }127 128 112 $allVars = _call_component($moduleName, $componentName, $vars); 129 113 … … 132 116 // render 133 117 $view = new sfPartialView($context, $moduleName, $actionName, ''); 118 $view->setPartialVars($vars); 134 119 $view->getAttributeHolder()->add($allVars); 135 120 136 $retval = $view->render(); 137 138 if ($cacheManager) 139 { 140 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $cacheManager->computeCacheKey($vars), $retval); 141 142 $context->setResponse($mainResponse); 143 $mainResponse->merge($response); 144 } 145 146 return $retval; 121 return $view->render(); 147 122 } 148 123 } … … 202 177 $actionName = '_'.$templateName; 203 178 204 if ($cacheManager = $context->getViewCacheManager())205 {206 $cacheManager->registerConfiguration($moduleName);207 208 $cacheKey = $cacheManager->computeCacheKey($vars);209 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $cacheKey))210 {211 return $retval;212 }213 else214 {215 $mainResponse = $context->getResponse();216 $responseClass = get_class($mainResponse);217 $context->setResponse($response = new $responseClass($context->getEventDispatcher(), $mainResponse->getOptions()));218 }219 }220 221 179 $view = new sfPartialView($context, $moduleName, $actionName, ''); 222 $view->getAttributeHolder()->add($vars); 223 224 $retval = $view->render(); 225 226 if ($cacheManager) 227 { 228 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $cacheKey, $retval); 229 $context->setResponse($mainResponse); 230 $mainResponse->merge($response); 231 } 232 233 return $retval; 180 $view->setPartialVars($vars); 181 182 return $view->render(); 234 183 } 235 184 branches/1.1/lib/view/sfPartialView.class.php
r7614 r7726 19 19 class sfPartialView extends sfPHPView 20 20 { 21 protected 22 $partialVars = array(); 23 21 24 /** 22 25 * Executes any presentation logic for this view. … … 24 27 public function execute() 25 28 { 29 } 30 31 public function setPartialVars(array $partialVars) 32 { 33 $this->partialVars = $partialVars; 26 34 } 27 35 … … 56 64 } 57 65 66 if ($cacheManager = $this->context->getViewCacheManager()) 67 { 68 $cacheManager->registerConfiguration($this->moduleName); 69 70 $cacheKey = $cacheManager->computeCacheKey($this->partialVars); 71 if ($retval = $cacheManager->getPartialCache($this->moduleName, $this->actionName, $cacheKey)) 72 { 73 return $retval; 74 } 75 else 76 { 77 $mainResponse = $this->context->getResponse(); 78 $responseClass = get_class($mainResponse); 79 $this->context->setResponse($response = new $responseClass($this->context->getEventDispatcher(), $mainResponse->getOptions())); 80 } 81 } 82 83 $this->getAttributeHolder()->add($this->partialVars); 84 58 85 // execute pre-render check 59 86 $this->preRenderCheck(); … … 61 88 // render template 62 89 $retval = $this->renderFile($this->getDirectory().'/'.$this->getTemplate()); 90 91 if ($cacheManager) 92 { 93 $retval = $cacheManager->setPartialCache($this->moduleName, $this->actionName, $cacheKey, $retval); 94 $this->context->setResponse($mainResponse); 95 $mainResponse->merge($response); 96 } 63 97 64 98 if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled'))