Changeset 11102
- Timestamp:
- 08/25/08 11:33:39 (10 months ago)
- Files:
-
- branches/1.2/UPGRADE_TO_1_2 (modified) (2 diffs)
- branches/1.2/lib/helper/AssetHelper.php (modified) (2 diffs)
- branches/1.2/lib/response/sfWebResponse.class.php (modified) (6 diffs)
- branches/1.2/test/unit/response/sfWebResponseTest.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.2/UPGRADE_TO_1_2
r11098 r11102 64 64 $response->addStylesheet('bar.css', 'first'); 65 65 66 var_export($response->getStylesheets( sfWebResponse::ALL));66 var_export($response->getStylesheets()); 67 67 68 68 // outputs … … 71 71 'foo.css' => array(), 72 72 ) 73 74 The `sfWebResponse::ALL` is also now the default value for the position argument. 75 In symfony 1.1, as the default value is the empty string, the methods only return 76 the files registered for the default position by default, which is not very intuitive. 73 77 74 78 In symfony 1.1, you was able to get all the files by passing the `'ALL'` string branches/1.2/lib/helper/AssetHelper.php
r11089 r11102 462 462 463 463 $html = ''; 464 foreach ($response->getJavascripts( sfWebResponse::ALL) as $file => $options)464 foreach ($response->getJavascripts() as $file => $options) 465 465 { 466 466 $html .= javascript_include_tag($file, $options); … … 495 495 496 496 $html = ''; 497 foreach ($response->getStylesheets( sfWebResponse::ALL) as $file => $options)497 foreach ($response->getStylesheets() as $file => $options) 498 498 { 499 499 $html .= stylesheet_tag($file, $options); branches/1.2/lib/response/sfWebResponse.class.php
r11098 r11102 585 585 * Retrieves stylesheets for the current web response. 586 586 * 587 * If you pass sfWebResponse::ALL as the position,588 * the methodsreturns all stylesheets ordered by position.587 * By default, the position is sfWebResponse::ALL, 588 * and the method returns all stylesheets ordered by position. 589 589 * 590 590 * @param string $position The position 591 591 * 592 * @return array An associative array of javascript files as keys and options as values593 */ 594 public function getStylesheets($position = '')595 { 596 if (s fWebResponse::ALL === $position)592 * @return array An associative array of stylesheet files as keys and options as values 593 */ 594 public function getStylesheets($position = self::ALL) 595 { 596 if (self::ALL === $position) 597 597 { 598 598 $stylesheets = array(); … … 607 607 return $stylesheets; 608 608 } 609 else if (s fWebResponse::RAW === $position)609 else if (self::RAW === $position) 610 610 { 611 611 return $this->stylesheets; … … 647 647 * Retrieves javascript files from the current web response. 648 648 * 649 * If you pass sfWebResponse::ALL as the position,650 * the methodsreturns all javascripts ordered by position.649 * By default, the position is sfWebResponse::ALL, 650 * and the method returns all javascripts ordered by position. 651 651 * 652 652 * @param string $position The position … … 654 654 * @return array An associative array of javascript files as keys and options as values 655 655 */ 656 public function getJavascripts($position = '')657 { 658 if (s fWebResponse::ALL === $position)656 public function getJavascripts($position = self::ALL) 657 { 658 if (self::ALL === $position) 659 659 { 660 660 $javascripts = array(); … … 669 669 return $javascripts; 670 670 } 671 else if (s fWebResponse::RAW === $position)671 else if (self::RAW === $position) 672 672 { 673 673 return $this->javascripts; … … 766 766 $this->metas = $response->getMetas(); 767 767 $this->httpMetas = $response->getHttpMetas(); 768 $this->stylesheets = $response->getStylesheets(s fWebResponse::RAW);769 $this->javascripts = $response->getJavascripts(s fWebResponse::RAW);768 $this->stylesheets = $response->getStylesheets(self::RAW); 769 $this->javascripts = $response->getJavascripts(self::RAW); 770 770 $this->slots = $response->getSlots(); 771 771 } branches/1.2/test/unit/response/sfWebResponseTest.php
r11098 r11102 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 79, new lime_output_color());13 $t = new lime_test(81, new lime_output_color()); 14 14 15 15 class myWebResponse extends sfWebResponse … … 218 218 // ->getStylesheets() 219 219 $t->diag('->getStylesheets()'); 220 $t->is($response->getStylesheets(), array('test' => array(), 'foo' => array(), 'bar' => array('media' => 'print')), '->getStylesheets() returns all current registered stylesheets'); 220 $t->is(array_keys($response->getStylesheets()), array('first', 'test', 'foo', 'bar', 'last'), '->getStylesheets() returns all current registered stylesheets ordered by position'); 221 $t->is($response->getStylesheets(''), array('test' => array(), 'foo' => array(), 'bar' => array('media' => 'print')), '->getStylesheets() takes a position as its first argument'); 221 222 $t->is($response->getStylesheets('first'), array('first' => array()), '->getStylesheets() takes a position as its first argument'); 222 223 $t->is($response->getStylesheets('last'), array('last' => array()), '->getStylesheets() takes a position as its first argument'); … … 224 225 $t->diag('->removeStylesheet()'); 225 226 $response->removeStylesheet('foo'); 226 $t->is(array_keys($response->getStylesheets( sfWebResponse::ALL)), array('first', 'test', 'bar', 'last'), '->getStylesheets() removes a stylesheet from the response');227 $t->is(array_keys($response->getStylesheets()), array('first', 'test', 'bar', 'last'), '->getStylesheets() removes a stylesheet from the response'); 227 228 228 229 $response->removeStylesheet('first'); 229 $t->is(array_keys($response->getStylesheets( sfWebResponse::ALL)), array('test', 'bar', 'last'), '->getStylesheets() removes a stylesheet from the response');230 $t->is(array_keys($response->getStylesheets()), array('test', 'bar', 'last'), '->getStylesheets() removes a stylesheet from the response'); 230 231 231 232 // ->addJavascript() … … 253 254 // ->getJavascripts() 254 255 $t->diag('->getJavascripts()'); 255 $t->is($response->getJavascripts(), array('test' => array(), 'foo' => array('raw_name' => true)), '->getJavascripts() returns all current registered javascripts'); 256 $t->is(array_keys($response->getJavascripts()), array('first_js', 'test', 'foo', 'last_js'), '->getJavascripts() returns all current registered javascripts ordered by position'); 257 $t->is($response->getJavascripts(''), array('test' => array(), 'foo' => array('raw_name' => true)), '->getJavascripts() takes a position as its first argument'); 256 258 $t->is($response->getJavascripts('first'), array('first_js' => array()), '->getJavascripts() takes a position as its first argument'); 257 259 $t->is($response->getJavascripts('last'), array('last_js' => array()), '->getJavascripts() takes a position as its first argument'); … … 259 261 $t->diag('->removeJavascript()'); 260 262 $response->removeJavascript('test'); 261 $t->is(array_keys($response->getJavascripts( sfWebResponse::ALL)), array('first_js', 'foo', 'last_js'), '->removeJavascripts() removes a javascript file');263 $t->is(array_keys($response->getJavascripts()), array('first_js', 'foo', 'last_js'), '->removeJavascripts() removes a javascript file'); 262 264 263 265 $response->removeJavascript('first_js'); 264 $t->is(array_keys($response->getJavascripts( sfWebResponse::ALL)), array('foo', 'last_js'), '->removeJavascripts() removes a javascript file');266 $t->is(array_keys($response->getJavascripts()), array('foo', 'last_js'), '->removeJavascripts() removes a javascript file'); 265 267 266 268 // ->setCookie() ->getCookies()

