Development

Changeset 11202

You must first sign up to be able to contribute.

Changeset 11202

Show
Ignore:
Timestamp:
08/27/08 17:08:56 (10 months ago)
Author:
fabien
Message:

[1.2] added the possibility to pass an array to url_for() and link_to() with the route name

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/controller/sfWebController.class.php

    r9956 r11202  
    3232  { 
    3333    // absolute URL or symfony URL? 
    34     if (!is_array($parameters) && preg_match('#^[a-z][a-z0-9\+.\-]*\://#i', $parameters)) 
     34    if (is_string($parameters) && preg_match('#^[a-z][a-z0-9\+.\-]*\://#i', $parameters)) 
    3535    { 
    3636      return $parameters; 
    3737    } 
    3838 
    39     if (!is_array($parameters) && $parameters == '#') 
     39    if (is_string($parameters) && $parameters == '#') 
    4040    { 
    4141      return $parameters; 
     
    5353    $fragment = ''; 
    5454 
    55     if (!is_array($parameters)) 
     55    if (is_string($parameters)) 
    5656    { 
    5757      // strip fragment 
     
    6363 
    6464      list($route_name, $parameters) = $this->convertUrlStringToParameters($parameters); 
     65    } 
     66    else if (is_array($parameters)) 
     67    { 
     68      if (isset($parameters['sf_route'])) 
     69      { 
     70        $route_name = $parameters['sf_route']; 
     71        unset($parameters['sf_route']); 
     72      } 
    6573    } 
    6674 
  • branches/1.2/test/unit/controller/sfWebControllerTest.php

    r9956 r11202  
    170170// ->genUrl() 
    171171$t->diag('->genUrl()'); 
    172  
    173 $r = $context->getRouting(); 
    174172$t->is($controller->genUrl('module/action?id=4'), $controller->genUrl(array('action' => 'action', 'module' => 'module', 'id' => 4)), '->genUrl() accepts a string or an array as its first argument'); 
    175173 
     
    203201$t->is($controller->genUrl('module/action'), $relativeUrlRoot.$_SERVER['SCRIPT_NAME'].$referenceUrl, '->genUrl() with a relative_url_root set and no_script_name==false'); 
    204202$t->is($controller->genUrl('@test'), $relativeUrlRoot.$_SERVER['SCRIPT_NAME'].$referenceRootUrl, '->genUrl() with a relative_url_root set and no_script_name==false (root url)'); 
    205  

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.