/** * @see sfWebController */ public function genUrl($parameters = array(), $absolute = false) { if (!defined('SID') || !SID) { return parent::genUrl($parameters, $absolute); } $isSid = false; if (is_string($parameters) && false !== ($sidPos = strpos($parameters, SID))) { $isSid = true; $paramHead = substr($parameters, 0, $sidPos); $paramFoot = substr($parameters, $sidPos + strlen(SID) + 1); $parameters = $paramHead . $paramFoot; } elseif (is_array($parameters) && in_array(session_name(), $parameters, true)) { $isSid = true; unset($parameters[session_name()]); } $url = parent::genUrl($parameters, $absolute); if ($isSid) { $fragment = ''; if (false !== ($fragPos = strpos($url, '#'))) { $fragment = substr($url, $fragPos); $url = substr($url, 0, $fragPos); } if (strpos($url, '?') === false) { $url .= '?'; } $url .= SID . $fragment; } return $url; }
/** * @see sfWebController */ public function genUrl($parameters = array(), $absolute = false) { $url = parent::genUrl($parameters, $absolute); if (sfJpMobile::isDocomo()) { if (!preg_match('/(\\?|&)guid=/', $url)) { $url .= (strpos($url, '?') === false ? '?' : '&') . 'guid=ON'; } } return $url; }
{ $t->pass('->redirect() throw an InvalidArgumentException when the url argument is null'); } catch(Exception $e) { $t->fail('->redirect() throw an InvalidArgumentException when the url argument is null. '.get_class($e).' was received'); } // Test empty string url argument for ->redirect() try { $controller->redirect(''); $t->fail('->redirect() throw an InvalidArgumentException when the url argument is an empty string'); } catch (InvalidArgumentException $iae) { $t->pass('->redirect() throw an InvalidArgumentException when the url argument is an empty string'); } catch(Exception $e) { $t->fail('->redirect() throw an InvalidArgumentException when the url argument is an empty string. '.get_class($e).' was received'); } // ->genUrl() $t->diag('->genUrl()'); $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'); $lastError = error_get_last(); $controller->genUrl(''); $t->is_deeply(error_get_last(), $lastError, '->genUrl() accepts an empty string');