Changeset 7723
- Timestamp:
- 03/03/08 12:24:09 (6 months ago)
- Files:
-
- branches/1.1/lib/response/sfWebResponse.class.php (modified) (1 diff)
- branches/1.1/lib/test/sfTestBrowser.class.php (modified) (1 diff)
- branches/1.1/lib/view/sfViewCacheManager.class.php (modified) (3 diffs)
- branches/1.1/test/unit/response/sfWebResponseTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/response/sfWebResponse.class.php
r7722 r7723 681 681 * @param sfWebResponse A sfWebResponse instance 682 682 */ 683 public function mergeProperties(sfWebResponse $response) 684 { 685 $this->options = $response->getOptions(); 686 $this->headers = $response->getHttpHeaders(); 687 $this->metas = $response->getMetas(); 688 $this->httpMetas = $response->getHttpMetas(); 689 $this->stylesheets = $response->getStylesheets('ALL'); 690 $this->javascripts = $response->getJavascripts('ALL'); 691 $this->slots = $response->getSlots(); 683 public function copyProperties(sfWebResponse $response) 684 { 685 $this->options = $response->getOptions(); 686 $this->headers = $response->getHttpHeaders(); 687 $this->metas = $response->getMetas(); 688 $this->httpMetas = $response->getHttpMetas(); 689 $this->stylesheets = $response->getStylesheets('ALL'); 690 $this->javascripts = $response->getJavascripts('ALL'); 691 $this->slots = $response->getSlots(); 692 } 693 694 /** 695 * Merges all properties from a given sfWebResponse object to the current one. 696 * 697 * @param sfWebResponse A sfWebResponse instance 698 */ 699 public function merge(sfWebResponse $response) 700 { 701 foreach ($this->getPositions() as $position) 702 { 703 $this->javascripts[$position] = array_merge($this->getJavascripts($position), $response->getJavascripts($position)); 704 $this->stylesheets[$position] = array_merge($this->getStylesheets($position), $response->getStylesheets($position)); 705 } 706 707 $this->slots = array_merge($this->getSlots(), $response->getSlots()); 692 708 } 693 709 branches/1.1/lib/test/sfTestBrowser.class.php
r5154 r7723 428 428 $this->test->ok($content == $this->getResponse()->getContent(), 'content in cache is ok'); 429 429 } 430 else if (true === $main)430 else 431 431 { 432 432 $ret = unserialize($cacheManager->get($uri)); 433 433 $content = $ret['content']; 434 $this->test->ok(false !== strpos($this->getResponse()->getContent(), $content), 'content in cache is ok');435 }436 else437 {438 $content = $cacheManager->get($uri);439 434 $this->test->ok(false !== strpos($this->getResponse()->getContent(), $content), 'content in cache is ok'); 440 435 } branches/1.1/lib/view/sfViewCacheManager.class.php
r7722 r7723 559 559 560 560 // retrieve content from cache 561 $c ontent= $this->get($uri);562 563 if (is_null($c ontent))561 $cache = $this->get($uri); 562 563 if (is_null($cache)) 564 564 { 565 565 return null; 566 566 } 567 568 $cache = unserialize($cache); 569 $content = $cache['content']; 570 $this->context->getResponse()->merge($cache['response']); 567 571 568 572 if (sfConfig::get('sf_web_debug')) … … 591 595 } 592 596 593 $saved = $this->set( $content, $uri);597 $saved = $this->set(serialize(array('content' => $content, 'response' => $this->context->getResponse())), $uri); 594 598 595 599 if ($saved && sfConfig::get('sf_web_debug')) … … 638 642 $content = $cache['content']; 639 643 $cache['response']->setEventDispatcher($this->dispatcher); 640 $this->context->getResponse()-> mergeProperties($cache['response']);644 $this->context->getResponse()->copyProperties($cache['response']); 641 645 642 646 if (sfConfig::get('sf_web_debug')) branches/1.1/test/unit/response/sfWebResponseTest.php
r7714 r7723 163 163 $t->is($response->getHttpHeader('Cache-Control'), 'max-age=12, no-cache', '->addCacheControlHttpHeader() respects ordering'); 164 164 165 // -> mergeProperties()166 $t->diag('-> mergeProperties()');165 // ->copyProperties() 166 $t->diag('->copyProperties()'); 167 167 $response1 = new myWebResponse($dispatcher); 168 168 $response2 = new myWebResponse($dispatcher); … … 172 172 $response1->setTitle('My title'); 173 173 174 $response2-> mergeProperties($response1);175 $t->is($response1->getHttpHeader('symfony'), $response2->getHttpHeader('symfony'), '-> mergeProperties() merges http headers');176 $t->is($response1->getContentType(), $response2->getContentType(), '-> mergeProperties() merges content type');177 $t->is($response1->getTitle(), $response2->getTitle(), '-> mergeProperties() merges titles');174 $response2->copyProperties($response1); 175 $t->is($response1->getHttpHeader('symfony'), $response2->getHttpHeader('symfony'), '->copyProperties() merges http headers'); 176 $t->is($response1->getContentType(), $response2->getContentType(), '->copyProperties() merges content type'); 177 $t->is($response1->getTitle(), $response2->getTitle(), '->copyProperties() merges titles'); 178 178 179 179 // ->addStylesheet()