当前位置: 首页>>代码示例>>PHP>>正文


PHP sfRoute::generate方法代码示例

本文整理汇总了PHP中sfRoute::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP sfRoute::generate方法的具体用法?PHP sfRoute::generate怎么用?PHP sfRoute::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfRoute的用法示例。


在下文中一共展示了sfRoute::generate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * Generates a URL from the given parameters.
  *
  * @param  mixed   $params    The parameter values
  * @param  array   $context   The context
  * @param  Boolean $absolute  Whether to generate an absolute URL
  *
  * @return string The generated URL
  */
 public function generate($params, $context = array(), $absolute = false)
 {
     $slug = null;
     if (isset($params['engine-slug'])) {
         $slug = $params['engine-slug'];
         aRouteTools::pushTargetEnginePage($slug);
         unset($params['engine-slug']);
     }
     // Note that you must pass false to parent::generate for the $absolute parameter
     $result = aRouteTools::addPageToUrl($this, parent::generate($params, $context, false), $absolute);
     if ($slug) {
         aRouteTools::popTargetEnginePage($slug);
     }
     return $result;
 }
开发者ID:quafzi,项目名称:timpany-prototype,代码行数:24,代码来源:aRoute.php

示例2: generate

 public function generate($params, $context = array(), $absolute = false)
 {
     $url = parent::generate($params, $context, $absolute);
     return 'http://' . $context['host'] . $url;
 }
开发者ID:sensorsix,项目名称:app,代码行数:5,代码来源:sfPatternRoutingTest.php

示例3: tokenizeBufferBefore

$t->diag('->parseStarParameter()');
$route = new sfRoute('/foo/*');
$t->is($route->matchesUrl('/foo/foo/bar/bar/foo'), array('foo' => 'bar', 'bar' => 'foo'), '->parseStarParameter() parses * as key/value pairs');
$t->is($route->matchesUrl('/foo/foo/foo.bar'), array('foo' => 'foo.bar'), '->parseStarParameter() uses / as the key/value separator');
$t->is($route->matchesUrl('/foo'), array(), '->parseStarParameter() returns no additional parameters if the * value is empty');
$route = new sfRoute('/foo/*', array('module' => 'foo'));
$t->is($route->matchesUrl('/foo/foo/bar/module/barbar'), array('foo' => 'bar', 'module' => 'foo'), '->parseStarParameter() cannot override a default value');
$route = new sfRoute('/:foo/*');
$t->is($route->matchesUrl('/bar/foo/barbar'), array('foo' => 'bar'), '->parseStarParameter() cannot override pattern variables');
$route = new sfRoute('/foo/*/bar');
$t->is($route->matchesUrl('/foo/foo/bar/bar'), array('foo' => 'bar'), '->parseStarParameter() is able to parse a star in the middle of a rule');
$t->is($route->matchesUrl('/foo/bar'), array(), '->parseStarParameter() is able to parse a star if it is empty');
// ->generateStarParameter()
$t->diag('->generateStarParameter()');
$route = new sfRoute('/foo/:foo/*');
$t->is($route->generate(array('foo' => 'bar', 'bar' => 'foo')), '/foo/bar/bar/foo', '->generateStarParameter() replaces * with all the key/pair values that are not variables');
// custom token
$t->diag('custom token');
class MyRoute extends sfRoute
{
    protected function tokenizeBufferBefore(&$buffer, &$tokens, &$afterASeparator, &$currentSeparator)
    {
        if ($afterASeparator && preg_match('#^=(' . $this->options['variable_regex'] . ')#', $buffer, $match)) {
            // a labelled variable
            $this->tokens[] = array('label', $currentSeparator, $match[0], $match[1]);
            $currentSeparator = '';
            $buffer = substr($buffer, strlen($match[0]));
            $afterASeparator = false;
        } else {
            return false;
        }
开发者ID:mediasadc,项目名称:alba,代码行数:31,代码来源:sfRouteTest.php

示例4: generate

 /**
  * @see sfRoute
  */
 public function generate($params, $context = array(), $absolute = false)
 {
     return parent::generate($this->filterParams($params), $context, $absolute);
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:7,代码来源:QubitRoute.class.php

示例5: generate

 /**
  * Generates a URL from the given parameters.
  *
  * @param  mixed   $params    The parameter values
  * @param  array   $context   The context
  * @param  Boolean $absolute  Whether to generate an absolute URL
  *
  * @return string The generated URL
  */
 public function generate($params, $context = array(), $absolute = false)
 {
     unset($params['sf_method']);
     return parent::generate($params, $context, $absolute);
 }
开发者ID:WIZARDISHUNGRY,项目名称:symfony,代码行数:14,代码来源:sfRequestRoute.class.php

示例6: generate

 /**
  * Generates a URL from the given parameters.
  *
  * @param  mixed   $params    The parameter values
  * @param  array   $context   The context
  * @param  Boolean $absolute  Whether to generate an absolute URL
  *
  * @return string The generated URL
  */
 public function generate($params, $context = array(), $absolute = false)
 {
     // Note that you must pass false to parent::generate for the $absolute parameter
     return aRouteTools::addPageToUrl($this, parent::generate($params, $context, false), $absolute);
 }
开发者ID:verenate,项目名称:gri,代码行数:14,代码来源:aRoute.php


注:本文中的sfRoute::generate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。