當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。