本文整理汇总了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('/');
}
}
}
示例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;
}
示例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;
}
示例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'));
}
示例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'));
}
示例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);
}
示例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'));
}
示例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'));
}
示例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 */
}