Development

Changeset 11098

You must first sign up to be able to contribute.

Changeset 11098

Show
Ignore:
Timestamp:
08/25/08 11:10:13 (10 months ago)
Author:
fabien
Message:

[1.2] fixed the behavior of the removeJavascript() and removeStylesheet() methods

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/UPGRADE_TO_1_2

    r11090 r11098  
    9999    sfWebResponse::LAST   === 'last' 
    100100 
     101The `removeStylesheet()` and `removeJavascript()` methods now only take one argument, 
     102the file to remove from the response. It will remove the file in all the available 
     103positions. In symfony 1.1, they take the position as a second argument. 
     104 
    101105Validators 
    102106---------- 
  • branches/1.2/lib/response/sfWebResponse.class.php

    r11089 r11098  
    634634   * Removes a stylesheet from the current web response. 
    635635   * 
    636    * @param string $css       The stylesheet fil
    637    * @param string $position  Position 
    638   */ 
    639   public function removeStylesheet($file, $position = '') 
    640   { 
    641     $this->validatePosition($position); 
    642  
    643     unset($this->stylesheets[$position][$file]); 
     636   * @param string $css The stylesheet file to remov
     637   */ 
     638  public function removeStylesheet($file) 
     639  { 
     640    foreach ($this->getPositions() as $position) 
     641    { 
     642      unset($this->stylesheets[$position][$file]); 
     643    } 
    644644  } 
    645645 
     
    696696   * Removes a JavaScript file from the current web response. 
    697697   * 
    698    * @param string $file      The Javascript fil
    699    * @param string $position  Position 
    700   */ 
    701   public function removeJavascript($file, $position = '') 
    702   { 
    703     $this->validatePosition($position); 
    704  
    705     unset($this->javascripts[$position][$file]); 
     698   * @param string $file The Javascript file to remov
     699   */ 
     700  public function removeJavascript($file) 
     701  { 
     702    foreach ($this->getPositions() as $position) 
     703    { 
     704      unset($this->javascripts[$position][$file]); 
     705    } 
    706706  } 
    707707 
  • branches/1.2/test/unit/response/sfWebResponseTest.php

    r11059 r11098  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(77, new lime_output_color()); 
     13$t = new lime_test(79, new lime_output_color()); 
    1414 
    1515class myWebResponse extends sfWebResponse 
     
    224224$t->diag('->removeStylesheet()'); 
    225225$response->removeStylesheet('foo'); 
    226 $t->is($response->getStylesheets(), array('test' => array(), 'bar' => array('media' => 'print')), '->getStylesheets() does no longer contain removed stylesheets'); 
     226$t->is(array_keys($response->getStylesheets(sfWebResponse::ALL)), array('first', 'test', 'bar', 'last'), '->getStylesheets() removes a stylesheet from the response'); 
     227 
     228$response->removeStylesheet('first'); 
     229$t->is(array_keys($response->getStylesheets(sfWebResponse::ALL)), array('test', 'bar', 'last'), '->getStylesheets() removes a stylesheet from the response'); 
    227230 
    228231// ->addJavascript() 
     
    256259$t->diag('->removeJavascript()'); 
    257260$response->removeJavascript('test'); 
    258 $t->is($response->getJavascripts(), array('foo' => array('raw_name' => true)), '->getJavascripts() does no longer contain removed javascripts'); 
     261$t->is(array_keys($response->getJavascripts(sfWebResponse::ALL)), array('first_js', 'foo', 'last_js'), '->removeJavascripts() removes a javascript file'); 
     262 
     263$response->removeJavascript('first_js'); 
     264$t->is(array_keys($response->getJavascripts(sfWebResponse::ALL)), array('foo', 'last_js'), '->removeJavascripts() removes a javascript file'); 
    259265 
    260266// ->setCookie() ->getCookies() 

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.