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


PHP sfRoute类代码示例

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


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

示例1: getObjectForRoute

 /**
  * Retrieves an object from the given route.
  *
  * @param sfRoute $route A sfRoute instance
  */
 protected function getObjectForRoute(sfRoute $route)
 {
     if ($route instanceof sfObjectRoute) {
         try {
             return $route->getObject();
         } catch (Exception $e) {
         }
     }
     return null;
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:15,代码来源:dcStatefulSecurityFilter.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: sfRoute

// ->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 = '';
            $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: getGlobPatterns

 protected function getGlobPatterns(sfRoute $route)
 {
     $routeOptions = $route->getOptions();
     $pathBase = $this->getOption('cache_dir');
     $pathStart = $this->getPathStart($route);
     $pathEnd = $this->getPathEnd($route);
     $depth = substr_count($pathStart . '*' . $pathEnd, '/');
     $paths = array();
     for ($i = $depth; $i <= $routeOptions['max_folder_depth']; $i++) {
         $paths[] = $pathBase . $pathStart . str_repeat('*/', $i - $depth) . '*' . $pathEnd;
     }
     return $paths;
 }
开发者ID:rafaelgou,项目名称:sfImageTransformExtraPlugin,代码行数:13,代码来源:sfRawFileCache.class.php

示例6: createHostRoute

 /**
  * Returns a new route object for inspecting and generating the host.
  *
  * @param string $pattern      The host pattern
  * @param array  $defaults     All defaults for the current route
  * @param array  $requirements All requirements for the current route
  * @param array  $options      All options for the current route
  *
  * @return sfRoute
  */
 protected function createHostRoute($pattern, $defaults, $requirements, $options)
 {
     $filteredDefaults = array();
     $filteredRequirements = array();
     // this temporary route is just for extracting variables from the pattern
     $tmp = new sfRoute($pattern);
     foreach (array_keys($tmp->getVariables()) as $name) {
         if (isset($defaults[$name])) {
             $filteredDefaults[$name] = $defaults[$name];
         }
         if (isset($requirements[$name])) {
             $filteredRequirements[$name] = $requirements[$name];
         }
     }
     return new sfRoute($pattern, $filteredDefaults, $filteredRequirements, $options);
 }
开发者ID:kriswallsmith,项目名称:sfHostAwareRoutingPlugin,代码行数:26,代码来源:sfHostAwareRoute.class.php

示例7: getContextEngineSlug

 /**
  * If an engine page has already been pushed or we are on an engine page now,
  * returns that engine page slug. Otherwise returns null. Useful to determine
  * whether you should get clever or not in a getEngineSlug() method for an
  * aDoctrineRoute.
  *
  * @param  sfRoute $route
  *
  * @return string The engine slug, or null
  */
 public static function getContextEngineSlug(sfRoute $route)
 {
     $defaults = $route->getDefaults();
     $currentPage = aTools::getCurrentPage();
     $engine = $defaults['module'];
     if (isset(self::$targetEnginePageSlugs[$engine]) && count(self::$targetEnginePageSlugs[$engine])) {
         return end(self::$targetEnginePageSlugs[$engine]);
     } elseif ($currentPage && $currentPage->engine === $defaults['module']) {
         return $currentPage->slug;
     } else {
         return null;
     }
 }
开发者ID:hashir,项目名称:UoA,代码行数:23,代码来源:aRouteTools.php

示例8: addPageToUrl

 /**
  * Prepends the current CMS page to the URL.
  *
  * @param  string $url The URL so far obtained from parent::generate
  * @param  Boolean $absolute  Whether to generate an absolute URL
  *
  * @return string The generated URL
  */
 public static function addPageToUrl(sfRoute $route, $url, $absolute)
 {
     $defaults = $route->getDefaults();
     $currentPage = aTools::getCurrentPage();
     $engine = $defaults['module'];
     if (isset(self::$targetEnginePages[$engine]) && count(self::$targetEnginePages[$engine])) {
         $page = end(self::$targetEnginePages[$engine]);
     } elseif (!$currentPage || $currentPage->engine !== $defaults['module']) {
         $page = aPageTable::getFirstEnginePage($defaults['module']);
     } else {
         $page = $currentPage;
     }
     if (!$page) {
         throw new sfException('Attempt to generate aRoute URL for module ' . $defaults['module'] . ' with no matching engine page on the site');
     }
     // A route URL of / for an engine route maps to the page itself, without a trailing /
     if ($url === '/') {
         $url = '';
     }
     // Ditto for / followed by a query string (missed this before)
     if (substr($url, 0, 2) === '/?') {
         $url = substr($url, 1);
     }
     $pageUrl = $page->getUrl($absolute);
     // Strip controller off so it doesn't duplicate the controller in the
     // URL we just generated. We could use the slug directly, but that would
     // break if the CMS were not mounted at the root on a particular site.
     // Take care to function properly in the presence of an absolute URL
     if (preg_match("/^(https?:\\/\\/[^\\/]+)?\\/[^\\/]+\\.php(.*)\$/", $pageUrl, $matches)) {
         $pageUrl = $matches[2];
     }
     return $pageUrl . $url;
 }
开发者ID:verenate,项目名称:gri,代码行数:41,代码来源:aRouteTools.php

示例9: configureRoute

 public function configureRoute(sfRoute $route)
 {
     $route->setDefaultParameters($this->defaultParameters);
     $route->setDefaultOptions($this->options);
 }
开发者ID:seven07ve,项目名称:vendorepuestos,代码行数:5,代码来源:config_core_compile.yml.php

示例10: getSecurityConfigForRoute

 /**
  * get the security settings for a route
  *
  * @param sfRoute $route
  * @return array
  */
 protected function getSecurityConfigForRoute(sfRoute $route)
 {
     $route_defaults = $route->getDefaults() ? $route->getDefaults() : $route->getDefaultParameters();
     $config = $this->context->getConfiguration();
     if ($file = $config->getConfigCache()->checkConfig('modules/' . $route_defaults['module'] . '/config/security.yml', true)) {
         require $file;
     } else {
         $this->security = array();
     }
     $secure = $this->getSecurityValue($route_defaults['action'], 'is_secure');
     $credentials = $this->getSecurityValue($route_defaults['action'], 'credentials');
     if (!is_null($credentials) && !is_array($credentials)) {
         $credentials = array($credentials);
     }
     return array('is_secure' => $secure, 'credentials' => $credentials);
 }
开发者ID:vicb,项目名称:ioMenuPlugin,代码行数:22,代码来源:ioMenuConfigHandler.class.php

示例11: fixSuffix

 protected function fixSuffix()
 {
     parent::fixSuffix();
     if (sfConfig::get('op_is_mail_address_contain_hash', false) && !$this->nonAuth) {
         $this->pattern = $this->pattern . '.:hash';
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:7,代码来源:opMailRoute.class.php

示例12: matchesParameters

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

示例13: 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

示例14: 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

示例15: 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


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