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


PHP Route::getPath方法代码示例

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


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

示例1: generateI18nPatterns

 /**
  * {@inheritDoc}
  */
 public function generateI18nPatterns($routeName, Route $route)
 {
     $patterns = array();
     foreach ($route->getOption('i18n_locales') ?: $this->locales as $locale) {
         // Check if translation exists in the translation catalogue to avoid errors being logged by
         // the new LoggingTranslator of Symfony 2.6. However, the LoggingTranslator did not implement
         // the interface until Symfony 2.6.5, so an extra check is needed.
         if ($this->translator instanceof TranslatorBagInterface || $this->translator instanceof LoggingTranslator) {
             // Check if route is translated.
             if (!$this->translator->getCatalogue($locale)->has($routeName, $this->translationDomain)) {
                 // No translation found.
                 $i18nPattern = $route->getPath();
             } else {
                 // Get translation.
                 $i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale);
             }
         } else {
             // if no translation exists, we use the current pattern
             if ($routeName === ($i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale))) {
                 $i18nPattern = $route->getPath();
             }
         }
         // prefix with locale if requested
         if (self::STRATEGY_PREFIX === $this->strategy || self::STRATEGY_PREFIX_EXCEPT_DEFAULT === $this->strategy && $this->defaultLocale !== $locale) {
             $i18nPattern = '/' . $locale . $i18nPattern;
             if (null !== $route->getOption('i18n_prefix')) {
                 $i18nPattern = $route->getOption('i18n_prefix') . $i18nPattern;
             }
         }
         $patterns[$i18nPattern][] = $locale;
     }
     return $patterns;
 }
开发者ID:DONIKAN,项目名称:JMSI18nRoutingBundle,代码行数:36,代码来源:DefaultPatternGenerationStrategy.php

示例2: testPath

 public function testPath()
 {
     $route = new Route('/{foo}');
     $route->setPath('/{bar}');
     $this->assertEquals('/{bar}', $route->getPath(), '->setPath() sets the path');
     $route->setPath('');
     $this->assertEquals('/', $route->getPath(), '->setPath() adds a / at the beginning of the path if needed');
     $route->setPath('bar');
     $this->assertEquals('/bar', $route->getPath(), '->setPath() adds a / at the beginning of the path if needed');
     $this->assertEquals($route, $route->setPath(''), '->setPath() implements a fluent interface');
     $route->setPath('//path');
     $this->assertEquals('/path', $route->getPath(), '->setPath() does not allow two slahes "//" at the beginning of the path as it would be confused with a network path when generating the path from the route');
 }
开发者ID:omusico,项目名称:lafayettehelps.com,代码行数:13,代码来源:RouteTest.php

示例3: generateI18nPatterns

 /**
  * {@inheritDoc}
  */
 public function generateI18nPatterns($routeName, Route $route)
 {
     $patterns = array();
     foreach ($route->getOption('i18n_locales') ?: $this->locales as $locale) {
         // Check if translation exists in the translation catalogue to avoid errors being logged by
         // the new LoggingTranslator of Symfony 2.6. However, the LoggingTranslator did not implement
         // the interface until Symfony 2.6.5, so an extra check is needed.
         if ($this->translator instanceof TranslatorBagInterface || $this->translator instanceof LoggingTranslator) {
             // Check if route is translated.
             if (!$this->translator->getCatalogue($locale)->has($routeName, $this->translationDomain)) {
                 // No translation found.
                 $i18nPattern = $route->getPath();
             } else {
                 // Get translation.
                 $i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale);
             }
         } else {
             // if no translation exists, we use the current pattern
             if ($routeName === ($i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale))) {
                 $i18nPattern = $route->getPath();
             }
         }
         ///////////////////////////////////////
         // Begin customizations
         // prefix with zikula module url if requested
         if ($route->hasDefault('_zkModule')) {
             $module = $route->getDefault('_zkModule');
             $zkNoBundlePrefix = $route->getOption('zkNoBundlePrefix');
             if (!isset($zkNoBundlePrefix) || !$zkNoBundlePrefix) {
                 $untranslatedPrefix = $this->getModUrlString($module);
                 if ($this->translator->getCatalogue($locale)->has($untranslatedPrefix, strtolower($module))) {
                     $prefix = $this->translator->trans($untranslatedPrefix, [], strtolower($module), $locale);
                 } else {
                     $prefix = $untranslatedPrefix;
                 }
                 $i18nPattern = "/" . $prefix . $i18nPattern;
             }
         }
         // End customizations
         ///////////////////////////////////////
         // prefix with locale if requested
         if (self::STRATEGY_PREFIX === $this->strategy || self::STRATEGY_PREFIX_EXCEPT_DEFAULT === $this->strategy && $this->defaultLocale !== $locale) {
             $i18nPattern = '/' . $locale . $i18nPattern;
             if (null !== $route->getOption('i18n_prefix')) {
                 $i18nPattern = $route->getOption('i18n_prefix') . $i18nPattern;
             }
         }
         $patterns[$i18nPattern][] = $locale;
     }
     return $patterns;
 }
开发者ID:Silwereth,项目名称:core,代码行数:54,代码来源:ZikulaPatternGenerationStrategy.php

示例4: __construct

 /**
  * Constructs a Route object.
  */
 public function __construct($name, Route $route, RouteProviderInterface $route_provider)
 {
     $this->name = $name;
     $this->route = $route;
     $this->routeProvider = $route_provider ? $route_provider : \Drupal::service('router.route_provider');
     $this->path = new PathUtility($route->getPath());
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:10,代码来源:RouteWrapper.php

示例5: describeRoute

    /**
     * {@inheritdoc}
     */
    protected function describeRoute(Route $route, array $options = array())
    {
        $requirements = $route->getRequirements();
        unset($requirements['_scheme'], $requirements['_method']);

        // fixme: values were originally written as raw
        $description = array(
            '<comment>Path</comment>         '.$route->getPath(),
            '<comment>Host</comment>         '.('' !== $route->getHost() ? $route->getHost() : 'ANY'),
            '<comment>Scheme</comment>       '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'),
            '<comment>Method</comment>       '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'),
            '<comment>Class</comment>        '.get_class($route),
            '<comment>Defaults</comment>     '.$this->formatRouterConfig($route->getDefaults()),
            '<comment>Requirements</comment> '.$this->formatRouterConfig($requirements) ?: 'NO CUSTOM',
            '<comment>Options</comment>      '.$this->formatRouterConfig($route->getOptions()),
            '<comment>Path-Regex</comment>   '.$route->compile()->getRegex(),
        );

        if (isset($options['name'])) {
            array_unshift($description, '<comment>Name</comment>         '.$options['name']);
            array_unshift($description, $this->formatSection('router', sprintf('Route "%s"', $options['name'])));
        }

        if (null !== $route->compile()->getHostRegex()) {
            $description[] = '<comment>Host-Regex</comment>   '.$route->compile()->getHostRegex();
        }

        $this->writeText(implode("\n", $description)."\n", $options);
    }
开发者ID:Gregwar,项目名称:symfony,代码行数:32,代码来源:TextDescriptor.php

示例6: describeRoute

 /**
  * {@inheritdoc}
  */
 protected function describeRoute(Route $route, array $options = array())
 {
     $tableHeaders = array('Property', 'Value');
     $tableRows = array(array('Route Name', $options['name']), array('Path', $route->getPath()), array('Path Regex', $route->compile()->getRegex()), array('Host', '' !== $route->getHost() ? $route->getHost() : 'ANY'), array('Host Regex', '' !== $route->getHost() ? $route->compile()->getHostRegex() : ''), array('Scheme', $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'), array('Method', $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'), array('Requirements', $route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM'), array('Class', get_class($route)), array('Defaults', $this->formatRouterConfig($route->getDefaults())), array('Options', $this->formatRouterConfig($route->getOptions())));
     $table = new Table($this->getOutput());
     $table->setHeaders($tableHeaders)->setRows($tableRows);
     $table->render();
 }
开发者ID:romankd,项目名称:symfony,代码行数:11,代码来源:TextDescriptor.php

示例7: describeRoute

 /**
  * {@inheritdoc}
  */
 protected function describeRoute(Route $route, array $options = array())
 {
     $requirements = $route->getRequirements();
     unset($requirements['_scheme'], $requirements['_method']);
     $output = '- Path: ' . $route->getPath() . "\n" . '- Host: ' . ('' !== $route->getHost() ? $route->getHost() : 'ANY') . "\n" . '- Scheme: ' . ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY') . "\n" . '- Method: ' . ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY') . "\n" . '- Class: ' . get_class($route) . "\n" . '- Defaults: ' . $this->formatRouterConfig($route->getDefaults()) . "\n" . '- Requirements: ' . $this->formatRouterConfig($requirements) ?: 'NONE' . "\n" . '- Options: ' . $this->formatRouterConfig($route->getOptions()) . "\n" . '- Path-Regex: ' . $route->compile()->getRegex();
     $this->write(isset($options['name']) ? $options['name'] . "\n" . str_repeat('-', strlen($options['name'])) . "\n\n" . $output : $output);
     $this->write("\n");
 }
开发者ID:makhloufi-lounis,项目名称:tuto_symfony,代码行数:11,代码来源:MarkdownDescriptor.php

示例8: getPath

 public function getPath()
 {
     if ($path = parent::getPath()) {
         return $path;
     }
     $defaults = $this->getDefaults();
     return $defaults['path'];
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:8,代码来源:Route.php

示例9: getActionForRoute

 /**
  * @param Route $route
  * @return Action
  */
 public function getActionForRoute(Route $route)
 {
     foreach ($this->actions as $action) {
         // TODO this should be improved to be more precise (route prefix)
         $sameSchema = strpos($route->getPath(), $action->getUrlSchema()) >= 0;
         $sameMethods = $action->getMethods() == $route->getMethods();
         if ($sameMethods && $sameSchema) {
             return $action;
         }
     }
 }
开发者ID:bitecodes,项目名称:rest-api-generator-bundle,代码行数:15,代码来源:ActionList.php

示例10: matchParams

 /**
  * @param Route $route
  * @param array $params
  * @return array
  */
 public function matchParams(Route $route, $params)
 {
     $ret = [];
     preg_match_all('/{(.*?)}/', $route->getPath(), $routeParams);
     foreach ($routeParams[1] as $param) {
         if (isset($params[$param])) {
             $ret[$param] = $this->entityAccessor->fetchIdentifier($params[$param]);
         }
     }
     return $ret;
 }
开发者ID:Qcumbeer,项目名称:QcumbeerBreadcrumbsBundle,代码行数:16,代码来源:RouteService.php

示例11: getEntryPath

 /**
  * @param Route $route
  *
  * @return string
  */
 protected function getEntryPath(Route $route)
 {
     $result = $route->getPath();
     if (false !== ($pos = strpos($result, '{version}'))) {
         $result = substr($result, $pos + 10);
     }
     if (false !== ($pos = strpos($result, '.{'))) {
         $result = substr($result, 0, $pos);
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:16,代码来源:OldOptionsRouteOptionsResolver.php

示例12: generateI18nPatterns

 public function generateI18nPatterns($routeName, Route $route)
 {
     $patterns = array();
     $config = $route->getOption('i18n');
     foreach ($this->locales as $locale) {
         // if no translation exists, we use the current pattern
         $i18nPattern = array_key_exists($locale, $config) ? $config[$locale] : $route->getPath();
         $i18nPattern = '/' . $locale . $i18nPattern;
         $patterns[$i18nPattern][] = $locale;
     }
     return $patterns;
 }
开发者ID:ehibes,项目名称:silexI18nRoutingServiceProvider,代码行数:12,代码来源:I18nControllerCollection.php

示例13: processOutbound

 /**
  * {@inheritdoc}
  */
 public function processOutbound(Route $route, array &$parameters)
 {
     if ($route->hasRequirement('_csrf_token')) {
         $path = ltrim($route->getPath(), '/');
         // Replace the path parameters with values from the parameters array.
         foreach ($parameters as $param => $value) {
             $path = str_replace("{{$param}}", $value, $path);
         }
         // Adding this to the parameters means it will get merged into the query
         // string when the route is compiled.
         $parameters['token'] = $this->csrfToken->get($path);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:16,代码来源:RouteProcessorCsrf.php

示例14: generateI18nPatterns

 public function generateI18nPatterns($routeName, Route $route)
 {
     $patterns = array();
     foreach ($route->getOption('i18n_locales') ?: $this->locales as $locale) {
         // if no translation exists, we use the current pattern
         if ($routeName === ($i18nPattern = $this->translator->trans($routeName, array(), $this->translationDomain, $locale))) {
             $i18nPattern = $route->getPath();
         }
         $i18nPattern = '/' . $locale . $i18nPattern;
         $patterns[$i18nPattern][] = $locale;
     }
     return $patterns;
 }
开发者ID:ehibes,项目名称:I18nRoutingServiceProvider,代码行数:13,代码来源:I18nControllerCollection.php

示例15: access

 /**
  * Checks access based on a CSRF token for the request.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request object.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match object.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, Request $request, RouteMatchInterface $route_match)
 {
     $parameters = $route_match->getRawParameters();
     $path = ltrim($route->getPath(), '/');
     // Replace the path parameters with values from the parameters array.
     foreach ($parameters as $param => $value) {
         $path = str_replace("{{$param}}", $value, $path);
     }
     if ($this->csrfToken->validate($request->query->get('token'), $path)) {
         $result = AccessResult::allowed();
     } else {
         $result = AccessResult::forbidden();
     }
     // Not cacheable because the CSRF token is highly dynamic.
     return $result->setCacheable(FALSE);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:CsrfAccessCheck.php


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