當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfRoute::setDefaultParameters方法代碼示例

本文整理匯總了PHP中sfRoute::setDefaultParameters方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfRoute::setDefaultParameters方法的具體用法?PHP sfRoute::setDefaultParameters怎麽用?PHP sfRoute::setDefaultParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfRoute的用法示例。


在下文中一共展示了sfRoute::setDefaultParameters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: configureRoute

 public function configureRoute(sfRoute $route)
 {
     $route->setDefaultParameters($this->defaultParameters);
     $route->setDefaultOptions($this->options);
 }
開發者ID:seven07ve,項目名稱:vendorepuestos,代碼行數:5,代碼來源:config_core_compile.yml.php

示例2: sfRoute

$route = new sfRoute('/:foo');
$t->is($route->matchesParameters(array()), false, '->matchesParameters() returns false if one of the pattern variable is not provided');
$route = new sfRoute('/:foo', array('foo' => 'bar'));
$t->is($route->matchesParameters(array()), true, '->matchesParameters() merges the default parameters with the provided parameters to match the route');
$route = new sfRoute('/:foo');
$t->is($route->matchesParameters(array('foo' => 'bar')), true, '->matchesParameters() matches if all variables are given as parameters');
$route = new sfRoute('/:foo');
$t->is($route->matchesParameters(array('foo' => '')), true, '->matchesParameters() matches if optional parameters empty');
$t->is($route->matchesParameters(array('foo' => null)), true, '->matchesParameters() matches if optional parameters empty');
/*
$route = new sfRoute('/:foo/bar');
$t->is($route->matchesParameters(array('foo' => '')), false, '->matchesParameters() does not match is required parameters are empty');
$t->is($route->matchesParameters(array('foo' => null)), false, '->matchesParameters() does not match is required parameters are empty');
*/
$route = new sfRoute('/:foo');
$route->setDefaultParameters(array('foo' => 'bar'));
$t->is($route->matchesParameters(array()), true, '->matchesParameters() merges the routing default parameters with the provided parameters to match the route');
$route = new sfRoute('/:foo', array(), array('foo' => '\\d+'));
$t->is($route->matchesParameters(array('foo' => 'bar')), false, '->matchesParameters() enforces requirements');
$route = new sfRoute('/:foo', array(), array('foo' => '\\d+'));
$t->is($route->matchesParameters(array('foo' => 12)), true, '->matchesParameters() enforces requirements');
$route = new sfRoute('/', array('foo' => 'bar'));
$t->is($route->matchesParameters(array('foo' => 'foobar')), false, '->matchesParameters() checks that there is no parameter that is not a pattern variable');
$route = new sfRoute('/', array('foo' => 'bar'));
$t->is($route->matchesParameters(array('foo' => 'bar')), true, '->matchesParameters() can override a parameter that is not a pattern variable if the value is the same as the default one');
$route = new sfRoute('/:foo', array('bar' => 'foo'));
$t->is($route->matchesParameters(array('foo' => 'bar', 'bar' => 'foo')), true, '->matchesParameters() can override a parameter that is not a pattern variable if the value is the same as the default one');
$route = new sfRoute('/:foo');
$t->is($route->matchesParameters(array('foo' => 'bar', 'bar' => 'foo')), true, '->generate() matches even if there are extra parameters');
$route = new sfRoute('/:foo', array(), array(), array('extra_parameters_as_query_string' => false));
$t->is($route->matchesParameters(array('foo' => 'bar', 'bar' => 'foo')), false, '->generate() does not match if there are extra parameters if extra_parameters_as_query_string is set to false');
開發者ID:mediasadc,項目名稱:alba,代碼行數:31,代碼來源:sfRouteTest.php


注:本文中的sfRoute::setDefaultParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。