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


PHP Route::getSchemes方法代码示例

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


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

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

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

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

示例4: handleRouteRequirements

 /**
  * {@inheritdoc}
  */
 protected function handleRouteRequirements($pathinfo, $name, Route $route)
 {
     // expression condition
     if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) {
         return array(self::REQUIREMENT_MISMATCH, null);
     }
     // check HTTP scheme requirement
     $scheme = $this->context->getScheme();
     $schemes = $route->getSchemes();
     if ($schemes && !$route->hasScheme($scheme)) {
         return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, current($schemes)));
     }
     return array(self::REQUIREMENT_MATCH, null);
 }
开发者ID:saj696,项目名称:pipe,代码行数:17,代码来源:RedirectableUrlMatcher.php

示例5: testSchemeIsBC

 public function testSchemeIsBC()
 {
     $route = new Route('/');
     $route->setRequirement('_scheme', 'http|https');
     $this->assertEquals('http|https', $route->getRequirement('_scheme'));
     $this->assertEquals(array('http', 'https'), $route->getSchemes());
     $route->setSchemes(array('hTTp'));
     $this->assertEquals('http', $route->getRequirement('_scheme'));
     $route->setSchemes(array());
     $this->assertNull($route->getRequirement('_scheme'));
 }
开发者ID:omusico,项目名称:lafayettehelps.com,代码行数:11,代码来源:RouteTest.php

示例6: compileRoute

    /**
     * Compiles a single Route to PHP code used to match it against the path info.
     *
     * @param Route       $route                A Route instance
     * @param string      $name                 The name of the Route
     * @param bool        $supportsRedirections Whether redirections are supported by the base class
     * @param string|null $parentPrefix         The prefix of the parent collection used to optimize the code
     *
     * @return string PHP code
     *
     * @throws \LogicException
     */
    private function compileRoute(Route $route, $name, $supportsRedirections, $parentPrefix = null)
    {
        $code = '';
        $compiledRoute = $route->compile();
        $conditions = array();
        $hasTrailingSlash = false;
        $matches = false;
        $hostMatches = false;
        $methods = $route->getMethods();
        // GET and HEAD are equivalent
        if (in_array('GET', $methods) && !in_array('HEAD', $methods)) {
            $methods[] = 'HEAD';
        }
        $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods));
        if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\\^(?P<url>.*?)\\$\\1#', $compiledRoute->getRegex(), $m)) {
            if ($supportsTrailingSlash && substr($m['url'], -1) === '/') {
                $conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
                $hasTrailingSlash = true;
            } else {
                $conditions[] = sprintf("\$pathinfo === %s", var_export(str_replace('\\', '', $m['url']), true));
            }
        } else {
            if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) {
                $conditions[] = sprintf("0 === strpos(\$pathinfo, %s)", var_export($compiledRoute->getStaticPrefix(), true));
            }
            $regex = $compiledRoute->getRegex();
            if ($supportsTrailingSlash && ($pos = strpos($regex, '/$'))) {
                $regex = substr($regex, 0, $pos) . '/?$' . substr($regex, $pos + 2);
                $hasTrailingSlash = true;
            }
            $conditions[] = sprintf("preg_match(%s, \$pathinfo, \$matches)", var_export($regex, true));
            $matches = true;
        }
        if ($compiledRoute->getHostVariables()) {
            $hostMatches = true;
        }
        if ($route->getCondition()) {
            $conditions[] = $this->getExpressionLanguage()->compile($route->getCondition(), array('context', 'request'));
        }
        $conditions = implode(' && ', $conditions);
        $code .= <<<EOF
        // {$name}
        if ({$conditions}) {

EOF;
        $gotoname = 'not_' . preg_replace('/[^A-Za-z0-9_]/', '', $name);
        if ($methods) {
            if (1 === count($methods)) {
                $code .= <<<EOF
            if (\$this->context->getMethod() != '{$methods['0']}') {
                \$allow[] = '{$methods['0']}';
                goto {$gotoname};
            }


EOF;
            } else {
                $methods = implode("', '", $methods);
                $code .= <<<EOF
            if (!in_array(\$this->context->getMethod(), array('{$methods}'))) {
                \$allow = array_merge(\$allow, array('{$methods}'));
                goto {$gotoname};
            }


EOF;
            }
        }
        if ($hasTrailingSlash) {
            $code .= <<<EOF
            if (substr(\$pathinfo, -1) !== '/') {
                return \$this->redirect(\$pathinfo.'/', '{$name}');
            }


EOF;
        }
        if ($schemes = $route->getSchemes()) {
            if (!$supportsRedirections) {
                throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.');
            }
            $schemes = str_replace("\n", '', var_export(array_flip($schemes), true));
            $code .= <<<EOF
            \$requiredSchemes = {$schemes};
            if (!isset(\$requiredSchemes[\$this->context->getScheme()])) {
                return \$this->redirect(\$pathinfo, '{$name}', key(\$requiredSchemes));
            }

//.........这里部分代码省略.........
开发者ID:jacobDaeHyung,项目名称:laravel_bus_reservation,代码行数:101,代码来源:PhpMatcherDumper.php

示例7: testScheme

 public function testScheme()
 {
     $route = new Route('/');
     $this->assertEquals(array(), $route->getSchemes(), 'schemes is initialized with array()');
     $this->assertFalse($route->hasScheme('http'));
     $route->setSchemes('hTTp');
     $this->assertEquals(array('http'), $route->getSchemes(), '->setSchemes() accepts a single scheme string and lowercases it');
     $this->assertTrue($route->hasScheme('htTp'));
     $this->assertFalse($route->hasScheme('httpS'));
     $route->setSchemes(array('HttpS', 'hTTp'));
     $this->assertEquals(array('https', 'http'), $route->getSchemes(), '->setSchemes() accepts an array of schemes and lowercases them');
     $this->assertTrue($route->hasScheme('htTp'));
     $this->assertTrue($route->hasScheme('httpS'));
 }
开发者ID:saj696,项目名称:pipe,代码行数:14,代码来源:RouteTest.php

示例8: getRouteData

 /**
  * @param Route $route
  *
  * @return array
  */
 protected function getRouteData(Route $route)
 {
     return array('path' => $route->getPath(), 'pathRegex' => $route->compile()->getRegex(), 'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY', 'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '', 'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY', 'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY', 'class' => get_class($route), 'defaults' => $route->getDefaults(), 'requirements' => $route->getRequirements() ?: 'NO CUSTOM', 'options' => $route->getOptions());
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:9,代码来源:JsonDescriptor.php

示例9: setSchemes

 /**
  * Sets the schemes (e.g. 'https') this route is restricted to.
  * So an empty array means that any scheme is allowed.
  *
  * This method implements a fluent interface.
  *
  * @param string|array $schemes The scheme or an array of schemes
  *
  * @return Route The current Route instance
  */
 public function setSchemes($schemes)
 {
     parent::setSchemes($schemes);
     $this->schemes = parent::getSchemes();
     return $this;
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:16,代码来源:Route.php

示例10: testLegacySchemeRequirement

 /**
  * @group legacy
  */
 public function testLegacySchemeRequirement()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $route = new Route('/');
     $route->setRequirement('_scheme', 'http|https');
     $this->assertEquals('http|https', $route->getRequirement('_scheme'));
     $this->assertEquals(array('http', 'https'), $route->getSchemes());
     $this->assertTrue($route->hasScheme('https'));
     $this->assertTrue($route->hasScheme('http'));
     $this->assertFalse($route->hasScheme('ftp'));
     $route->setSchemes(array('hTTp'));
     $this->assertEquals('http', $route->getRequirement('_scheme'));
     $route->setSchemes(array());
     $this->assertNull($route->getRequirement('_scheme'));
 }
开发者ID:hilmysyarif,项目名称:sisfito,代码行数:18,代码来源:RouteTest.php

示例11: testLegacySchemeRequirement

 /**
  * @group legacy
  */
 public function testLegacySchemeRequirement()
 {
     $route = new Route('/');
     $route->setRequirement('_scheme', 'http|https');
     $this->assertEquals('http|https', $route->getRequirement('_scheme'));
     $this->assertEquals(array('http', 'https'), $route->getSchemes());
     $this->assertTrue($route->hasScheme('https'));
     $this->assertTrue($route->hasScheme('http'));
     $this->assertFalse($route->hasScheme('ftp'));
     $route->setSchemes(array('hTTp'));
     $this->assertEquals('http', $route->getRequirement('_scheme'));
     $route->setSchemes(array());
     $this->assertNull($route->getRequirement('_scheme'));
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:17,代码来源:RouteTest.php

示例12: cloneRoute

 /**
  * Makes a clone of the given Route object.
  *
  * @param Route $route
  *
  * @return Route
  */
 public function cloneRoute(Route $route)
 {
     return new Route($route->getPath(), $route->getDefaults(), $route->getRequirements(), $route->getOptions(), $route->getHost(), $route->getSchemes(), $route->getMethods());
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:RouteCollectionAccessor.php

示例13: addPageRoute

 public function addPageRoute($admin_name, $action_name, \Symfony\Component\Routing\Route $route, \ReflectionMethod $m, \Symforce\AdminBundle\Compiler\Annotation\Route $annot)
 {
     if (null === $this->route_page_collection) {
         throw new \Exception('should call getRouteCollection first');
     }
     $_path = array('s' => $route->getSchemes(), 'h' => $route->getHost(), 'p' => $route->getPath(), 'm' => $route->getMethods());
     $path = json_encode($_path);
     $admin_action = $admin_name . ':' . $action_name;
     if (isset($this->page_path_map[$path])) {
         $_admin_action = $this->page_path_map[$path];
         throw new \Exception(sprintf("web page path:`%s` duplicate(%s,%s)", $route->getPath(), $this->page_actions_map[$admin_action], $this->page_actions_map[$_admin_action]));
     }
     $this->page_path_map[$path] = $admin_action;
     if (isset($this->page_route_map[$annot->name])) {
         $_admin_action = $this->page_route_map[$annot->name];
         throw new \Exception(sprintf("web page route name:`%s` duplicate method(%s,%s), action(%s,%s)", $annot->name, $this->page_actions_map[$admin_action], $this->page_actions_map[$_admin_action], $admin_action, $_admin_action));
     }
     $this->page_route_map[$annot->name] = $admin_action;
     $this->route_page_collection->add($annot->name, $route);
     $this->page_dispatch_map[$admin_action] = array('name' => $annot->name, 'path' => $route->getPath(), 'requirements' => $route->getRequirements(), 'entity' => $annot->entity, 'template' => $annot->template, 'generator' => null, 'dispatcher' => null);
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:21,代码来源:RouteCacheLoader.php

示例14: describeRoute

 /**
  * Returns a descriptive string for a Route.
  *
  * @param Route  $route           A BackBee Route instance
  * @param string $routeName       The Route name (the associated index in a RouteCollection)
  * @param bool   $showControllers If true, display the Controller information
  *
  * @return string The text description of a Route
  */
 private function describeRoute(Route $route, $routeName, $showControllers)
 {
     $description = array('<comment>Name</comment>         ' . $routeName, '<comment>Path</comment>         ' . $route->getPath(), '<comment>Path Regex</comment>   ' . $route->compile()->getRegex(), '<comment>Host</comment>         ' . ('' !== $route->getHost() ? $route->getHost() : 'ANY'), '<comment>Host Regex</comment>   ' . ('' !== $route->getHost() ? $route->compile()->getHostRegex() : ''), '<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> ' . ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM'), '<comment>Options</comment>      ' . $this->formatRouterConfig($route->getOptions()));
     if (isset($showControllers)) {
         array_unshift($description, '<comment>Controller</comment>   ' . $this->convertController($route));
     }
     return implode("\n", $description) . "\n";
 }
开发者ID:backbee,项目名称:debug-bundle,代码行数:17,代码来源:DebugRoutingCommand.php

示例15: handleRouteRequirements

 /**
  * Handles specific route requirements.
  *
  * @param string $pathinfo The path
  * @param string $name     The route name
  * @param Route  $route    The route
  *
  * @return array The first element represents the status, the second contains additional information
  */
 protected function handleRouteRequirements(Request $request, $pathinfo, $name, Route $route)
 {
     // expression condition
     if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) {
         return array(self::REQUIREMENT_MISMATCH, null);
     }
     // check HTTP scheme requirement
     $scheme = $request->getScheme();
     $status = $route->getSchemes() && !$route->hasScheme($scheme) ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH;
     return array($status, null);
 }
开发者ID:voxsim,项目名称:minima,代码行数:20,代码来源:UrlMatcher.php


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