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


PHP Route::setSchemes方法代码示例

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


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

示例1: processOutbound

 /**
  * {@inheritdoc}
  */
 public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL)
 {
     if ($route_name === '<current>') {
         if ($current_route = $this->routeMatch->getRouteObject()) {
             $requirements = $current_route->getRequirements();
             // Setting _method and _schema is deprecated since 2.7. Using
             // setMethods() and setSchemes() are now the recommended ways.
             unset($requirements['_method']);
             unset($requirements['_schema']);
             $route->setRequirements($requirements);
             $route->setPath($current_route->getPath());
             $route->setSchemes($current_route->getSchemes());
             $route->setMethods($current_route->getMethods());
             $route->setOptions($current_route->getOptions());
             $route->setDefaults($current_route->getDefaults());
             $parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
             if ($bubbleable_metadata) {
                 $bubbleable_metadata->addCacheContexts(['route']);
             }
         } else {
             // If we have no current route match available, point to the frontpage.
             $route->setPath('/');
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:RouteProcessorCurrent.php

示例2: format

 /**
  * Given an array of RAML\Resources, this function will add each Resource
  * into the Symfony Route Collection, and set the corresponding method.
  *
  * @param BasicRoute[Resource] $resources
  *  Associative array where the key is the method and full path, and the value contains
  *  the path, method type (GET/POST etc.) and then the Raml\Method object
  *
  * @return array
  */
 public function format(array $resources)
 {
     // Loop over the Resources
     foreach ($resources as $path => $resource) {
         // This is the path from the RAML, with or without a /.
         $path = $resource->getUri() . ($this->addTrailingSlash ? '/' : '');
         // This is the baseUri + path, the complete URL.
         $url = $resource->getBaseUrl() . $path;
         // Now remove the host away, so we have the FULL path to the resource.
         // baseUri may also contain path that has been omitted for brevity in the
         // RAML creation.
         $host = parse_url($url, PHP_URL_HOST);
         $fullPath = substr($url, strpos($url, $host) + strlen($host));
         // Now build our Route class.
         $route = new Route($fullPath);
         $route->setMethods($resource->getMethod()->getType());
         $route->setSchemes($resource->getProtocols());
         // Loop over each of the URI Parameters searching for validation patterns
         // or default values for parameters.
         foreach ($resource->getUriParameters() as $name => $param) {
             $route->setRequirement($name, $param->getValidationPattern());
             if ($default = $param->getDefault()) {
                 $route->setDefault($name, $default);
             }
         }
         $this->routes->add($resource->getType() . ' ' . $path, $route);
     }
     return $resources;
 }
开发者ID:TheKnarf,项目名称:php-raml-parser,代码行数:39,代码来源:SymfonyRouteFormatter.php

示例3: format

 /**
  * Given an array of RAML\Resources, this function will add each Resource
  * into the Symfony Route Collection, and set the corresponding method.
  *
  * @param BasicRoute[] $resources
  *  Associative array where the key is the method and full path, and the value contains
  *  the path, method type (GET/POST etc.) and then the Raml\Method object
  *
  * @return array
  */
 public function format(array $resources)
 {
     foreach ($resources as $path => $resource) {
         // This is the path from the RAML, with or without a /.
         $path = $resource->getUri() . ($this->addTrailingSlash ? '/' : '');
         // This is the baseUri + path, the complete URL.
         $url = $resource->getBaseUrl() . $path;
         // Now remove the host away, so we have the FULL path to the resource.
         // baseUri may also contain path that has been omitted for brevity in the
         // RAML creation.
         $host = parse_url($url, PHP_URL_HOST);
         $fullPath = substr($url, strpos($url, $host) + strlen($host));
         // Now build our Route class.
         $route = new Route($fullPath);
         $route->setMethods($resource->getMethod()->getType());
         $route->setSchemes($resource->getProtocols());
         $this->routes->add($resource->getType() . ' ' . $path, $route);
     }
     return $resources;
 }
开发者ID:eerootsus,项目名称:php-raml-parser,代码行数:30,代码来源:SymfonyRouteFormatter.php

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

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

示例6: refreshEntity

 /**
  * Refresh the entity
  *
  * @ORM\PostLoad
  */
 public function refreshEntity()
 {
     parent::setPath($this->path);
     parent::setDefaults($this->defaults);
     parent::setRequirements($this->requirements);
     parent::setOptions($this->options);
     parent::setHost($this->host);
     parent::setMethods($this->methods);
     parent::setSchemes($this->schemes);
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:15,代码来源:Route.php

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

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

示例9: __construct

 public function __construct()
 {
     $this->request = Request::createFromGlobals();
     $this->container = Container::getInstance();
     /* Parse params file - Begin */
     $params = $this->parseYamlFile(APP_DIR . DS . 'configs' . DS . 'params.yml');
     $isDev = $params['environment'] === 'development';
     if ($isDev) {
         Debug::enable(E_STRICT);
     }
     date_default_timezone_set($params['timezone']);
     /* Parse params file - End */
     /* Parse routes file - Begin */
     $routes = $this->parseYamlFile(APP_DIR . DS . 'configs' . DS . 'routes.yml');
     $collection = new RouteCollection();
     foreach ($routes as $name => $options) {
         $parts = explode(':', $options['defaults']['_controller']);
         $options['defaults'] = array('_controller' => "{$parts[0]}\\Controllers\\{$parts[1]}Controller::{$parts[2]}Action");
         $route = new Route($options['path']);
         $route->setDefaults($options['defaults']);
         $route->setRequirements(isset($options['requirements']) ? $options['requirements'] : array());
         $route->setOptions(isset($options['options']) ? $options['options'] : array());
         $route->setHost(isset($options['host']) ? $options['host'] : '');
         $route->setSchemes(isset($options['schemes']) ? $options['schemes'] : array());
         $route->setMethods(isset($options['methods']) ? $options['methods'] : array());
         $route->setCondition(isset($options['condition']) ? $options['condition'] : '');
         $collection->add($name, $route);
     }
     $this->container->setParameter('routes', $collection);
     /* Parse routes file - End */
     /* Composer ClassLoader - Begin */
     $composer_loader = new ClassLoader();
     $composer_loader->addPsr4('Application\\Controllers\\', APP_DIR . DS . 'layers' . DS . 'controllers');
     $composer_loader->addPsr4('Application\\Models\\', APP_DIR . DS . 'layers' . DS . 'models');
     $composer_loader->register();
     /* Composer ClassLoader - End */
     /* Set error controller - Begin */
     $namespace = $isDev ? 'Hideks\\Controller\\' : 'Application\\Controllers\\';
     $this->container->setParameter('exception.controller', $namespace . 'ErrorController::exceptionAction');
     /* Set error controller - End */
     /* Assetic configuration setup - Begin */
     $filter_manager = new FilterManager();
     $filter_manager->set('css_min', new CssMinFilter());
     $filter_manager->set('lessphp', new LessphpFilter());
     $filter_manager->set('js_min', new JSMinFilter());
     $asset_factory = new AssetFactory(APP_DIR . DS . 'assets' . DS);
     $asset_factory->setDebug($isDev);
     $asset_factory->setFilterManager($filter_manager);
     $asset_factory->addWorker(new CacheBustingWorker());
     $this->container->setParameter('assetic.factory', $asset_factory);
     /* Assetic configuration setup - End */
     /* Twig configuration setup - Begin */
     $this->container->setParameter('twig.debug', $isDev);
     $this->container->setParameter('twig.cache', $isDev ? false : APP_DIR . DS . 'cache' . DS . 'twig');
     $twig_loader = $this->container->get('twig.loader');
     $twig_loader->addPath(APP_DIR . DS . 'layers' . DS . 'views');
     /* Twig configuration setup - End */
     /* Active Record configuration setup - Begin */
     $active_record = \ActiveRecord\Config::instance();
     $active_record->set_model_directory(APP_DIR . DS . 'layers' . DS . 'models');
     $active_record->set_connections($params['connections']);
     $active_record->set_default_connection($params['environment']);
     /* Active Record configuration setup - End */
 }
开发者ID:hidekscorporation,项目名称:hideksframework2,代码行数:64,代码来源:Application.php


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