Development

Changeset 10834

You must first sign up to be able to contribute.

Changeset 10834

Show
Ignore:
Timestamp:
08/13/08 13:43:15 (11 months ago)
Author:
fabien
Message:

[1.2] added an optional argument to redirectIf and redirectUnless to change the status code (closes #3974)

Files:

Legend:

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

    r10832 r10834  
    5454---------- 
    5555 
    56 The `sfValidatorSchemaCompare` constant values have been changed. No change to your code need to be done, but now, you can use nice shortcuts. The following two examples are equivalent: 
     56The `sfValidatorSchemaCompare` constant values have been changed. No change to 
     57your code need to be done, but now, you can use nice shortcuts. 
     58The following two examples are equivalent: 
    5759 
    5860    [php] 
     
    6668----- 
    6769 
    68 Cookies are now extensively supported in the `sfBrowser` and `sfTestBrowser` classes. 
     70Cookies are now extensively supported in the `sfBrowser` and `sfTestBrowser` 
     71classes. 
    6972 
    70 You can manage cookies between requests by using the `setCookie()`, `removeCookie()`, and `clearCookies()` methods of the `sfBrowser` class: 
     73You can manage cookies between requests by using the `setCookie()`, 
     74`removeCookie()`, and `clearCookies()` methods of the `sfBrowser` class: 
    7175 
    7276    [php] 
     
    8185      // ... 
    8286 
    83 You can also test cookies with the `hasCookie()` and `isCookie()` methods of the `sfTestBrowser` class: 
     87You can also test cookies with the `hasCookie()` and `isCookie()` methods of 
     88the `sfTestBrowser` class: 
    8489 
    8590    [php] 
     
    9297      isCookie('foo', '/!z/')-> 
    9398 
    94 The `hasCookie()` method takes a Boolean as its second argument to be able to test the fact that a cookie is not set. 
     99The `hasCookie()` method takes a Boolean as its second argument to be able to 
     100test the fact that a cookie is not set. 
    95101 
    96 The second argument of the `isCookie()` method behaves as the second argument of the `checkElementResponse` method. It can be a string, a regular expression, or a negative regular expression. 
     102The second argument of the `isCookie()` method behaves as the second argument 
     103of the `checkElementResponse` method. It can be a string, a regular expression, 
     104or a negative regular expression. 
    97105 
    98 The browser class also automatically expires cookies as per the `expire` value of each cookie. 
     106The browser class also automatically expires cookies as per the `expire` value 
     107of each cookie. 
    99108 
    100109YAML 
    101110---- 
    102111 
    103 The YAML parser now supports full merge key (see http://yaml.org/type/merge.html for more examples). 
     112The YAML parser now supports full merge key (see http://yaml.org/type/merge.html 
     113for more examples). 
    104114 
    105115    [php] 
     
    146156 
    147157    ) 
     158 
     159Actions 
     160------- 
     161 
     162By default, when you use the `redirectIf()` or `redirectUnless()` methods 
     163in your actions, symfony automatically changes the response HTTP status 
     164code to 302. 
     165 
     166These two methods now have an additional optional argument to change this 
     167default status code: 
     168 
     169    [php] 
     170    $this->redirectIf($condition, '@homepage', 301); 
     171    $this->redirectUnless($condition, '@homepage', 301); 
     172 
     173The `redirect()` method already have this feature. 
  • branches/1.2/lib/action/sfAction.class.php

    r9477 r10834  
    205205   * @param  bool   $condition  A condition that evaluates to true or false 
    206206   * @param  string $url        Url 
     207   * @param  string $statusCode Status code (default to 302) 
    207208   * 
    208209   * @throws sfStopException 
     
    210211   * @see redirect 
    211212   */ 
    212   public function redirectIf($condition, $url
     213  public function redirectIf($condition, $url, $statusCode = 302
    213214  { 
    214215    if ($condition) 
    215216    { 
    216       $this->redirect($url); 
     217      $this->redirect($url, $statusCode); 
    217218    } 
    218219  } 
     
    225226   * @param  bool   $condition  A condition that evaluates to true or false 
    226227   * @param  string $url        Url 
     228   * @param  string $statusCode Status code (default to 302) 
    227229   * 
    228230   * @throws sfStopException 
     
    230232   * @see redirect 
    231233   */ 
    232   public function redirectUnless($condition, $url
     234  public function redirectUnless($condition, $url, $statusCode = 302
    233235  { 
    234236    if (!$condition) 
    235237    { 
    236       $this->redirect($url); 
     238      $this->redirect($url, $statusCode); 
    237239    } 
    238240  } 

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.