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


PHP sfRoute::matchesUrl方法代码示例

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


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

示例1: matchesUrl

 /**
  * Returns true if the URL matches this route, false otherwise.
  *
  * @param  string  $url     The URL
  * @param  array   $context The context
  *
  * @return array   An array of parameters
  */
 public function matchesUrl($url, $context = array())
 {
     if (false === ($parameters = parent::matchesUrl($url, $context))) {
         return false;
     }
     // enforce the sf_method requirement
     if (in_array(strtolower($context['method']), $this->requirements['sf_method'])) {
         return $parameters;
     }
     return false;
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:19,代码来源:sfRequestRoute.class.php

示例2: matchesUrl

 /**
  * @see    sfRoute
  * @param  string  $url     The URL
  * @param  array   $context The context
  * @return array   An array of parameters
  */
 public function matchesUrl($url, $context = array())
 {
     $parameters = parent::matchesUrl($url, $context);
     $matches = array();
     if (preg_match('/^([^(]+)(\\(.*\\))(\\..*?)$/', $parameters['file_name'], $matches)) {
         $parameters['file_name'] = $matches[1] . $matches[3];
         preg_match_all('/\\((.*?):(.*?)\\)/', $matches[2], $matches);
         $parameters = array_merge($parameters, $this->matchParameters($matches[1], $matches[2]));
     }
     return $parameters;
 }
开发者ID:jakzal,项目名称:gyImagenePlugin,代码行数:17,代码来源:gyImageneFileRoute.class.php

示例3: matchesUrl

 public function matchesUrl($url, $context = array())
 {
     $result = parent::matchesUrl($url, $context);
     if (!$result) {
         return $result;
     }
     $message = array('This routing rule is deprecated. Please use other rules instead of this.', 'priority' => sfLogger::NOTICE);
     if (sfContext::hasInstance()) {
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($this, 'application.log', $message));
     }
     return $result;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:12,代码来源:opDeprecatedRoute.class.php

示例4: matchesUrl

 /**
  * Returns true if the URL matches this route, false otherwise.
  *
  * @param  string  $url     The URL
  * @param  array   $context The context
  *
  * @return array   An array of parameters
  */
 public function matchesUrl($url, $context = array())
 {
     if (false === ($parameters = parent::matchesUrl($url, $context))) {
         return false;
     }
     if (!isset($this->requirements['sf_method'])) {
         $this->requirements['sf_method'] = array('get', 'head');
     }
     // enforce the sf_method requirement
     $methods = is_array($this->requirements['sf_method']) ? $this->requirements['sf_method'] : array($this->requirements['sf_method']);
     foreach ($methods as $method) {
         if (0 == strcasecmp($method, $context['method'])) {
             return $parameters;
         }
     }
     return false;
 }
开发者ID:WIZARDISHUNGRY,项目名称:symfony,代码行数:25,代码来源:sfRequestRoute.class.php

示例5: matchesUrl

 public function matchesUrl($url, $context = array())
 {
     $culture = $this->getCulture($context);
     if (isset($this->requirements['sf_host_culture'])) {
         $sfHostCulture = $this->requirements['sf_host_culture'];
         if ($culture != $sfHostCulture) {
             return false;
         }
     }
     /*
     if (isset($this->requirements['reviewFilter'])) {
     	$reviewFilter = $this->requirements['reviewFilter'];
     	
     	return parent::matchesUrl(urldecode($url), $context);
     }
     */
     return parent::matchesUrl(urldecode($url), $context);
 }
开发者ID:voota,项目名称:voota,代码行数:18,代码来源:sfRequestHostCultureRoute.php

示例6: matchesUrl

 /**
  * Returns true if the URL matches this route, false otherwise.
  *
  * @param  string  $url     The URL
  * @param  array   $context The context
  *
  * @return array   An array of parameters
  */
 public function matchesUrl($url, $context = array())
 {
     $url = aRouteTools::removePageFromUrl($this, $url);
     return parent::matchesUrl($url, $context);
 }
开发者ID:hashir,项目名称:UoA,代码行数:13,代码来源:aRoute.php

示例7: tokenizeBufferBefore

$route = new sfRoute('/:foo/:bar', array('bar' => 'foo'));
$t->is($route->generate(array('foo' => 'bar')), '/bar', '->generate() generates the shortest URL possible');
$route = new sfRoute('/:foo/:bar', array('bar' => 'foo'), array(), array('generate_shortest_url' => false));
$t->is($route->generate(array('foo' => 'bar')), '/bar/foo', '->generate() generates the longest URL possible if generate_shortest_url is false');
// ->parseStarParameter()
$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 = '';
开发者ID:mediasadc,项目名称:alba,代码行数:31,代码来源:sfRouteTest.php


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