merged branch fabpot/hostname-rename (PR #6825)

This PR was merged into the master branch.

Commits
-------

94f6116 renamed hostname to host in the routing system (closes #6775)
001734a [Validator] fixed phpdoc
18b9e68 [HttpFoundation] renamed hostname to host in the test to be consistent

Discussion
----------

Hostname rename to host

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no (does not exist in 2.1)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6775
| License       | MIT
| Doc PR        | symfony/symfony-docs#2165

see #6775

---------------------------------------------------------------------------

by WouterJ at 2013-01-21T18:44:20Z

+1
This commit is contained in:
Fabien Potencier 2013-01-21 21:04:57 +01:00
commit 52124ebdc0
40 changed files with 268 additions and 268 deletions

View File

@ -83,7 +83,7 @@ EOF
$maxName = strlen('name');
$maxMethod = strlen('method');
$maxHostname = strlen('hostname');
$maxHost = strlen('host');
foreach ($routes as $name => $route) {
$requirements = $route->getRequirements();
@ -92,16 +92,16 @@ EOF
? implode(', ', $requirements['_method']) : $requirements['_method']
)
: 'ANY';
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
$maxName = max($maxName, strlen($name));
$maxMethod = max($maxMethod, strlen($method));
$maxHostname = max($maxHostname, strlen($hostname));
$maxHost = max($maxHost, strlen($host));
}
$format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxHostname.'s %s';
$format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxHost.'s %s';
// displays the generated routes
$format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHostname + 19).'s %s';
$output->writeln(sprintf($format1, '<comment>Name</comment>', '<comment>Method</comment>', '<comment>Hostname</comment>', '<comment>Pattern</comment>'));
$format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHost + 19).'s %s';
$output->writeln(sprintf($format1, '<comment>Name</comment>', '<comment>Method</comment>', '<comment>Host</comment>', '<comment>Pattern</comment>'));
foreach ($routes as $name => $route) {
$requirements = $route->getRequirements();
$method = isset($requirements['_method'])
@ -109,8 +109,8 @@ EOF
? implode(', ', $requirements['_method']) : $requirements['_method']
)
: 'ANY';
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
$output->writeln(sprintf($format, $name, $method, $hostname, $route->getPath()));
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
$output->writeln(sprintf($format, $name, $method, $host, $route->getPath()));
}
}
@ -124,13 +124,13 @@ EOF
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
}
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));
$output->writeln(sprintf('<comment>Name</comment> %s', $name));
$output->writeln(sprintf('<comment>Pattern</comment> %s', $route->getPath()));
$output->writeln(sprintf('<comment>Hostname</comment> %s', $hostname));
$output->writeln(sprintf('<comment>Host</comment> %s', $host));
$output->writeln(sprintf('<comment>Class</comment> %s', get_class($route)));
$defaults = '';

View File

@ -78,7 +78,7 @@ class Router extends BaseRouter implements WarmableInterface
* - the route defaults,
* - the route requirements,
* - the route pattern.
* - the route hostname.
* - the route host.
*
* @param RouteCollection $collection
*/
@ -94,7 +94,7 @@ class Router extends BaseRouter implements WarmableInterface
}
$route->setPath($this->resolve($route->getPath()));
$route->setHostname($this->resolve($route->getHostname()));
$route->setHost($this->resolve($route->getHost()));
}
}

View File

@ -117,12 +117,12 @@ class RoutingTest extends \PHPUnit_Framework_TestCase
);
}
public function testHostnamePlaceholders()
public function testHostPlaceholders()
{
$routes = new RouteCollection();
$route = new Route('foo');
$route->setHostname('/before/%parameter.foo%/after/%%unescaped%%');
$route->setHost('/before/%parameter.foo%/after/%%unescaped%%');
$routes->add('foo', $route);
@ -136,7 +136,7 @@ class RoutingTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
'/before/foo/after/%unescaped%',
$route->getHostname()
$route->getHost()
);
}

View File

@ -303,9 +303,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$server = array();
// Standard Request on non default PORT
// http://hostname:8080/index.php/path/info?query=string
// http://host:8080/index.php/path/info?query=string
$server['HTTP_HOST'] = 'hostname:8080';
$server['HTTP_HOST'] = 'host:8080';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '8080';
@ -321,16 +321,16 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname:8080/index.php/path/info?query=string', $request->getUri(), '->getUri() with non default port');
$this->assertEquals('http://host:8080/index.php/path/info?query=string', $request->getUri(), '->getUri() with non default port');
// Use std port number
$server['HTTP_HOST'] = 'hostname';
$server['HTTP_HOST'] = 'host';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port');
$this->assertEquals('http://host/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port');
// Without HOST HEADER
unset($server['HTTP_HOST']);
@ -344,9 +344,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
// Request with URL REWRITING (hide index.php)
// RewriteCond %{REQUEST_FILENAME} !-f
// RewriteRule ^(.*)$ index.php [QSA,L]
// http://hostname:8080/path/info?query=string
// http://host:8080/path/info?query=string
$server = array();
$server['HTTP_HOST'] = 'hostname:8080';
$server['HTTP_HOST'] = 'host:8080';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '8080';
@ -360,17 +360,17 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$server['SCRIPT_FILENAME'] = '/some/where/index.php';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname:8080/path/info?query=string', $request->getUri(), '->getUri() with rewrite');
$this->assertEquals('http://host:8080/path/info?query=string', $request->getUri(), '->getUri() with rewrite');
// Use std port number
// http://hostname/path/info?query=string
$server['HTTP_HOST'] = 'hostname';
// http://host/path/info?query=string
$server['HTTP_HOST'] = 'host';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname/path/info?query=string', $request->getUri(), '->getUri() with rewrite and default port');
$this->assertEquals('http://host/path/info?query=string', $request->getUri(), '->getUri() with rewrite and default port');
// Without HOST HEADER
unset($server['HTTP_HOST']);
@ -384,7 +384,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
// With encoded characters
$server = array(
'HTTP_HOST' => 'hostname:8080',
'HTTP_HOST' => 'host:8080',
'SERVER_NAME' => 'servername',
'SERVER_PORT' => '8080',
'QUERY_STRING' => 'query=string',
@ -398,7 +398,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals(
'http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string',
'http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string',
$request->getUri()
);
@ -406,11 +406,11 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$server['PHP_AUTH_USER'] = 'fabien';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
$this->assertEquals('http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
$server['PHP_AUTH_PW'] = 'symfony';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
$this->assertEquals('http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
}
/**
@ -433,9 +433,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$server = array();
// Standard Request on non default PORT
// http://hostname:8080/index.php/path/info?query=string
// http://host:8080/index.php/path/info?query=string
$server['HTTP_HOST'] = 'hostname:8080';
$server['HTTP_HOST'] = 'host:8080';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '8080';
@ -451,16 +451,16 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$request->initialize(array(), array(), array(), array(), array(),$server);
$this->assertEquals('http://hostname:8080/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with non default port');
$this->assertEquals('http://host:8080/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with non default port');
// Use std port number
$server['HTTP_HOST'] = 'hostname';
$server['HTTP_HOST'] = 'host';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port');
$this->assertEquals('http://host/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port');
// Without HOST HEADER
unset($server['HTTP_HOST']);
@ -474,9 +474,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
// Request with URL REWRITING (hide index.php)
// RewriteCond %{REQUEST_FILENAME} !-f
// RewriteRule ^(.*)$ index.php [QSA,L]
// http://hostname:8080/path/info?query=string
// http://host:8080/path/info?query=string
$server = array();
$server['HTTP_HOST'] = 'hostname:8080';
$server['HTTP_HOST'] = 'host:8080';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '8080';
@ -490,17 +490,17 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$server['SCRIPT_FILENAME'] = '/some/where/index.php';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname:8080/some/path', $request->getUriForPath('/some/path'), '->getUri() with rewrite');
$this->assertEquals('http://host:8080/some/path', $request->getUriForPath('/some/path'), '->getUri() with rewrite');
// Use std port number
// http://hostname/path/info?query=string
$server['HTTP_HOST'] = 'hostname';
// http://host/path/info?query=string
$server['HTTP_HOST'] = 'host';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('http://hostname/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite and default port');
$this->assertEquals('http://host/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite and default port');
// Without HOST HEADER
unset($server['HTTP_HOST']);

View File

@ -25,7 +25,7 @@ class Route
private $requirements;
private $options;
private $defaults;
private $hostname;
private $host;
private $methods;
private $schemes;
@ -84,14 +84,14 @@ class Route
return $this->path;
}
public function setHostname($pattern)
public function setHost($pattern)
{
$this->hostname = $pattern;
$this->host = $pattern;
}
public function getHostname()
public function getHost()
{
return $this->hostname;
return $this->host;
}
public function setName($name)

View File

@ -23,9 +23,9 @@ class CompiledRoute
private $staticPrefix;
private $regex;
private $pathVariables;
private $hostnameVariables;
private $hostnameRegex;
private $hostnameTokens;
private $hostVariables;
private $hostRegex;
private $hostTokens;
/**
* Constructor.
@ -34,20 +34,20 @@ class CompiledRoute
* @param string $regex The regular expression to use to match this route
* @param array $tokens An array of tokens to use to generate URL for this route
* @param array $pathVariables An array of path variables
* @param string|null $hostnameRegex Hostname regex
* @param array $hostnameTokens Hostname tokens
* @param array $hostnameVariables An array of hostname variables
* @param array $variables An array of variables (variables defined in the path and in the hostname patterns)
* @param string|null $hostRegex Host regex
* @param array $hostTokens Host tokens
* @param array $hostVariables An array of host variables
* @param array $variables An array of variables (variables defined in the path and in the host patterns)
*/
public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostnameRegex = null, array $hostnameTokens = array(), array $hostnameVariables = array(), array $variables = array())
public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
{
$this->staticPrefix = (string) $staticPrefix;
$this->regex = $regex;
$this->tokens = $tokens;
$this->pathVariables = $pathVariables;
$this->hostnameRegex = $hostnameRegex;
$this->hostnameTokens = $hostnameTokens;
$this->hostnameVariables = $hostnameVariables;
$this->hostRegex = $hostRegex;
$this->hostTokens = $hostTokens;
$this->hostVariables = $hostVariables;
$this->variables = $variables;
}
@ -72,13 +72,13 @@ class CompiledRoute
}
/**
* Returns the hostname regex
* Returns the host regex
*
* @return string|null The hostname regex or null
* @return string|null The host regex or null
*/
public function getHostnameRegex()
public function getHostRegex()
{
return $this->hostnameRegex;
return $this->hostRegex;
}
/**
@ -92,13 +92,13 @@ class CompiledRoute
}
/**
* Returns the hostname tokens.
* Returns the host tokens.
*
* @return array The tokens
*/
public function getHostnameTokens()
public function getHostTokens()
{
return $this->hostnameTokens;
return $this->hostTokens;
}
/**
@ -122,13 +122,13 @@ class CompiledRoute
}
/**
* Returns the hostname variables.
* Returns the host variables.
*
* @return array The variables
*/
public function getHostnameVariables()
public function getHostVariables()
{
return $this->hostnameVariables;
return $this->hostVariables;
}
}

View File

@ -91,7 +91,7 @@ EOF;
$properties[] = $route->getDefaults();
$properties[] = $route->getRequirements();
$properties[] = $compiledRoute->getTokens();
$properties[] = $compiledRoute->getHostnameTokens();
$properties[] = $compiledRoute->getHostTokens();
$routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true)));
}
@ -114,9 +114,9 @@ EOF;
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', \$name));
}
list(\$variables, \$defaults, \$requirements, \$tokens, \$hostnameTokens) = self::\$declaredRoutes[\$name];
list(\$variables, \$defaults, \$requirements, \$tokens, \$hostTokens) = self::\$declaredRoutes[\$name];
return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$referenceType, \$hostnameTokens);
return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$referenceType, \$hostTokens);
}
EOF;
}

View File

@ -137,7 +137,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
// the Route has a cache of its own and is not recompiled as long as it does not get modified
$compiledRoute = $route->compile();
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostnameTokens());
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens());
}
/**
@ -145,7 +145,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
* it does not match the requirement
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostnameTokens)
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens)
{
$variables = array_flip($variables);
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
@ -209,9 +209,9 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
$scheme = $req;
}
if ($hostnameTokens) {
if ($hostTokens) {
$routeHost = '';
foreach ($hostnameTokens as $token) {
foreach ($hostTokens as $token) {
if ('variable' === $token[0]) {
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#', $mergedParams[$token[3]])) {
$message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]);
@ -272,7 +272,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
/**
* Returns the target path as relative reference from the base path.
*
* Only the URIs path component (no schema, hostname etc.) is relevant and must be given, starting with a slash.
* Only the URIs path component (no schema, host etc.) is relevant and must be given, starting with a slash.
* Both paths must be absolute and not contain relative parts.
* Relative URLs from one resource to another are useful when generating self-contained downloadable document archives.
* Furthermore, they can be used to reduce the link size in documents.

View File

@ -51,7 +51,7 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
/**
* Generates a network path, e.g. "//example.com/dir/file".
* Such reference reuses the current scheme but specifies the hostname.
* Such reference reuses the current scheme but specifies the host.
*/
const NETWORK_PATH = 'network';
@ -59,13 +59,13 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
* Generates a URL or path for a specific route based on the given parameters.
*
* Parameters that reference placeholders in the route pattern will substitute them in the
* path or hostname. Extra params are added as query string to the URL.
* path or host. Extra params are added as query string to the URL.
*
* When the passed reference type cannot be generated for the route because it requires a different
* hostname or scheme than the current one, the method will return a more comprehensive reference
* host or scheme than the current one, the method will return a more comprehensive reference
* that includes the required params. For example, when you call this method with $referenceType = ABSOLUTE_PATH
* but the route requires the https scheme whereas the current scheme is http, it will instead return an
* ABSOLUTE_URL with the https scheme and the current hostname. This makes sure the generated URL matches
* ABSOLUTE_URL with the https scheme and the current host. This makes sure the generated URL matches
* the route in any case.
*
* If there is no route with the given name, the generator must throw the RouteNotFoundException.

View File

@ -30,7 +30,7 @@ use Symfony\Component\Config\Loader\LoaderResolverInterface;
*
* The @Route annotation main value is the route path. The annotation also
* recognizes several parameters: requirements, options, defaults, schemes,
* methods, hostname, and name. The name parameter is mandatory.
* methods, host, and name. The name parameter is mandatory.
* Here is an example of how you should be able to use it:
*
* /**
@ -115,7 +115,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
'defaults' => array(),
'schemes' => array(),
'methods' => array(),
'hostname' => '',
'host' => '',
);
$class = new \ReflectionClass($class);
@ -151,8 +151,8 @@ abstract class AnnotationClassLoader implements LoaderInterface
$globals['methods'] = $annot->getMethods();
}
if (null !== $annot->getHostname()) {
$globals['hostname'] = $annot->getHostname();
if (null !== $annot->getHost()) {
$globals['host'] = $annot->getHost();
}
}
@ -189,12 +189,12 @@ abstract class AnnotationClassLoader implements LoaderInterface
$schemes = array_replace($globals['schemes'], $annot->getSchemes());
$methods = array_replace($globals['methods'], $annot->getMethods());
$hostname = $annot->getHostname();
if (null === $hostname) {
$hostname = $globals['hostname'];
$host = $annot->getHost();
if (null === $host) {
$host = $globals['host'];
}
$route = new Route($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $hostname, $schemes, $methods);
$route = new Route($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $host, $schemes, $methods);
$this->configureRoute($route, $class, $method, $annot);

View File

@ -131,7 +131,7 @@ class XmlFileLoader extends FileLoader
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
$route = new Route($node->getAttribute('path'), $defaults, $requirements, $options, $node->getAttribute('hostname'), $schemes, $methods);
$route = new Route($node->getAttribute('path'), $defaults, $requirements, $options, $node->getAttribute('host'), $schemes, $methods);
$collection->add($id, $route);
}
@ -153,7 +153,7 @@ class XmlFileLoader extends FileLoader
$type = $node->getAttribute('type');
$prefix = $node->getAttribute('prefix');
$hostname = $node->hasAttribute('hostname') ? $node->getAttribute('hostname') : null;
$host = $node->hasAttribute('host') ? $node->getAttribute('host') : null;
$schemes = $node->hasAttribute('schemes') ? array_filter(explode(' ', $node->getAttribute('schemes'))) : null;
$methods = $node->hasAttribute('methods') ? array_filter(explode(' ', $node->getAttribute('methods'))) : null;
@ -164,8 +164,8 @@ class XmlFileLoader extends FileLoader
$subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file);
/* @var $subCollection RouteCollection */
$subCollection->addPrefix($prefix);
if (null !== $hostname) {
$subCollection->setHostname($hostname);
if (null !== $host) {
$subCollection->setHost($host);
}
if (null !== $schemes) {
$subCollection->setSchemes($schemes);

View File

@ -28,7 +28,7 @@ use Symfony\Component\Config\Loader\FileLoader;
class YamlFileLoader extends FileLoader
{
private static $availableKeys = array(
'resource', 'type', 'prefix', 'pattern', 'path', 'hostname', 'schemes', 'methods', 'defaults', 'requirements', 'options',
'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options',
);
/**
@ -107,11 +107,11 @@ class YamlFileLoader extends FileLoader
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
$options = isset($config['options']) ? $config['options'] : array();
$hostname = isset($config['hostname']) ? $config['hostname'] : '';
$host = isset($config['host']) ? $config['host'] : '';
$schemes = isset($config['schemes']) ? $config['schemes'] : array();
$methods = isset($config['methods']) ? $config['methods'] : array();
$route = new Route($config['path'], $defaults, $requirements, $options, $hostname, $schemes, $methods);
$route = new Route($config['path'], $defaults, $requirements, $options, $host, $schemes, $methods);
$collection->add($name, $route);
}
@ -131,7 +131,7 @@ class YamlFileLoader extends FileLoader
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
$options = isset($config['options']) ? $config['options'] : array();
$hostname = isset($config['hostname']) ? $config['hostname'] : null;
$host = isset($config['host']) ? $config['host'] : null;
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
$methods = isset($config['methods']) ? $config['methods'] : null;
@ -140,8 +140,8 @@ class YamlFileLoader extends FileLoader
$subCollection = $this->import($config['resource'], $type, false, $file);
/* @var $subCollection RouteCollection */
$subCollection->addPrefix($prefix);
if (null !== $hostname) {
$subCollection->setHostname($hostname);
if (null !== $host) {
$subCollection->setHost($host);
}
if (null !== $schemes) {
$subCollection->setSchemes($schemes);

View File

@ -48,7 +48,7 @@
<xsd:attribute name="id" type="xsd:string" use="required" />
<xsd:attribute name="path" type="xsd:string" />
<xsd:attribute name="pattern" type="xsd:string" />
<xsd:attribute name="hostname" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="schemes" type="stringlist" />
<xsd:attribute name="methods" type="stringlist" />
</xsd:complexType>
@ -59,7 +59,7 @@
<xsd:attribute name="resource" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="prefix" type="xsd:string" />
<xsd:attribute name="hostname" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="schemes" type="stringlist" />
<xsd:attribute name="methods" type="stringlist" />
</xsd:complexType>

View File

@ -46,30 +46,30 @@ class ApacheMatcherDumper extends MatcherDumper
$rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]");
$methodVars = array();
$hostnameRegexUnique = 0;
$prevHostnameRegex = '';
$hostRegexUnique = 0;
$prevHostRegex = '';
foreach ($this->getRoutes()->all() as $name => $route) {
$compiledRoute = $route->compile();
$hostnameRegex = $compiledRoute->getHostnameRegex();
$hostRegex = $compiledRoute->getHostRegex();
if (null !== $hostnameRegex && $prevHostnameRegex !== $hostnameRegex) {
$prevHostnameRegex = $hostnameRegex;
$hostnameRegexUnique++;
if (null !== $hostRegex && $prevHostRegex !== $hostRegex) {
$prevHostRegex = $hostRegex;
$hostRegexUnique++;
$rule = array();
$regex = $this->regexToApacheRegex($hostnameRegex);
$regex = $this->regexToApacheRegex($hostRegex);
$regex = self::escape($regex, ' ', '\\');
$rule[] = sprintf('RewriteCond %%{HTTP:Host} %s', $regex);
$variables = array();
$variables[] = sprintf('E=__ROUTING_hostname_%s:1', $hostnameRegexUnique);
$variables[] = sprintf('E=__ROUTING_host_%s:1', $hostRegexUnique);
foreach ($compiledRoute->getHostnameVariables() as $i => $variable) {
$variables[] = sprintf('E=__ROUTING_hostname_%s_%s:%%%d', $hostnameRegexUnique, $variable, $i+1);
foreach ($compiledRoute->getHostVariables() as $i => $variable) {
$variables[] = sprintf('E=__ROUTING_host_%s_%s:%%%d', $hostRegexUnique, $variable, $i+1);
}
$variables = implode(',', $variables);
@ -79,7 +79,7 @@ class ApacheMatcherDumper extends MatcherDumper
$rules[] = implode("\n", $rule);
}
$rules[] = $this->dumpRoute($name, $route, $options, $hostnameRegexUnique);
$rules[] = $this->dumpRoute($name, $route, $options, $hostRegexUnique);
if ($req = $route->getRequirement('_method')) {
$methods = explode('|', strtoupper($req));
@ -109,11 +109,11 @@ class ApacheMatcherDumper extends MatcherDumper
* @param string $name Route name
* @param Route $route The route
* @param array $options Options
* @param bool $hostnameRegexUnique Unique identifier for the hostname regex
* @param bool $hostRegexUnique Unique identifier for the host regex
*
* @return string The compiled route
*/
private function dumpRoute($name, $route, array $options, $hostnameRegexUnique)
private function dumpRoute($name, $route, array $options, $hostRegexUnique)
{
$compiledRoute = $route->compile();
@ -126,8 +126,8 @@ class ApacheMatcherDumper extends MatcherDumper
$hasTrailingSlash = (!$methods || in_array('HEAD', $methods)) && '/$' === substr($regex, -2) && '^/$' !== $regex;
$variables = array('E=_ROUTING_route:'.$name);
foreach ($compiledRoute->getHostnameVariables() as $variable) {
$variables[] = sprintf('E=_ROUTING_param_%s:%%{ENV:__ROUTING_hostname_%s_%s}', $variable, $hostnameRegexUnique, $variable);
foreach ($compiledRoute->getHostVariables() as $variable) {
$variables[] = sprintf('E=_ROUTING_param_%s:%%{ENV:__ROUTING_host_%s_%s}', $variable, $hostRegexUnique, $variable);
}
foreach ($compiledRoute->getPathVariables() as $i => $variable) {
$variables[] = 'E=_ROUTING_param_'.$variable.':%'.($i + 1);
@ -151,8 +151,8 @@ class ApacheMatcherDumper extends MatcherDumper
$allow[] = 'E=_ROUTING_allow_'.$method.':1';
}
if ($hostnameRegex = $compiledRoute->getHostnameRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_hostname_%s} =1", $hostnameRegexUnique);
if ($hostRegex = $compiledRoute->getHostRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique);
}
$rule[] = "RewriteCond %{REQUEST_URI} $regex";
@ -163,8 +163,8 @@ class ApacheMatcherDumper extends MatcherDumper
// redirect with trailing slash appended
if ($hasTrailingSlash) {
if ($hostnameRegex = $compiledRoute->getHostnameRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_hostname_%s} =1", $hostnameRegexUnique);
if ($hostRegex = $compiledRoute->getHostRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique);
}
$rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$';
@ -173,8 +173,8 @@ class ApacheMatcherDumper extends MatcherDumper
// the main rule
if ($hostnameRegex = $compiledRoute->getHostnameRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_hostname_%s} =1", $hostnameRegexUnique);
if ($hostRegex = $compiledRoute->getHostRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique);
}
$rule[] = "RewriteCond %{REQUEST_URI} $regex";

View File

@ -109,19 +109,19 @@ EOF;
*/
private function compileRoutes(RouteCollection $routes, $supportsRedirections)
{
$fetchedHostname = false;
$fetchedHost = false;
$groups = $this->groupRoutesByHostnameRegex($routes);
$groups = $this->groupRoutesByHostRegex($routes);
$code = '';
foreach ($groups as $collection) {
if (null !== $regex = $collection->getAttribute('hostname_regex')) {
if (!$fetchedHostname) {
$code .= " \$hostname = \$this->context->getHost();\n\n";
$fetchedHostname = true;
if (null !== $regex = $collection->getAttribute('host_regex')) {
if (!$fetchedHost) {
$code .= " \$host = \$this->context->getHost();\n\n";
$fetchedHost = true;
}
$code .= sprintf(" if (preg_match(%s, \$hostname, \$hostnameMatches)) {\n", var_export($regex, true));
$code .= sprintf(" if (preg_match(%s, \$host, \$hostMatches)) {\n", var_export($regex, true));
}
$tree = $this->buildPrefixTree($collection);
@ -198,7 +198,7 @@ EOF;
$conditions = array();
$hasTrailingSlash = false;
$matches = false;
$hostnameMatches = false;
$hostMatches = false;
$methods = array();
if ($req = $route->getRequirement('_method')) {
@ -233,8 +233,8 @@ EOF;
$matches = true;
}
if ($compiledRoute->getHostnameVariables()) {
$hostnameMatches = true;
if ($compiledRoute->getHostVariables()) {
$hostMatches = true;
}
$conditions = implode(' && ', $conditions);
@ -295,10 +295,10 @@ EOF;
}
// optimize parameters array
if ($matches || $hostnameMatches) {
if ($matches || $hostMatches) {
$vars = array();
if ($hostnameMatches) {
$vars[] = '$hostnameMatches';
if ($hostMatches) {
$vars[] = '$hostMatches';
}
if ($matches) {
$vars[] = '$matches';
@ -323,27 +323,27 @@ EOF;
}
/**
* Groups consecutive routes having the same hostname regex.
* Groups consecutive routes having the same host regex.
*
* The result is a collection of collections of routes having the same hostname regex.
* The result is a collection of collections of routes having the same host regex.
*
* @param RouteCollection $routes A flat RouteCollection
*
* @return DumperCollection A collection with routes grouped by hostname regex in sub-collections
* @return DumperCollection A collection with routes grouped by host regex in sub-collections
*/
private function groupRoutesByHostnameRegex(RouteCollection $routes)
private function groupRoutesByHostRegex(RouteCollection $routes)
{
$groups = new DumperCollection();
$currentGroup = new DumperCollection();
$currentGroup->setAttribute('hostname_regex', null);
$currentGroup->setAttribute('host_regex', null);
$groups->add($currentGroup);
foreach ($routes as $name => $route) {
$hostnameRegex = $route->compile()->getHostnameRegex();
if ($currentGroup->getAttribute('hostname_regex') !== $hostnameRegex) {
$hostRegex = $route->compile()->getHostRegex();
if ($currentGroup->getAttribute('host_regex') !== $hostRegex) {
$currentGroup = new DumperCollection();
$currentGroup->setAttribute('hostname_regex', $hostnameRegex);
$currentGroup->setAttribute('host_regex', $hostRegex);
$groups->add($currentGroup);
}
$currentGroup->add(new DumperRoute($name, $route));

View File

@ -116,8 +116,8 @@ class UrlMatcher implements UrlMatcherInterface
continue;
}
$hostnameMatches = array();
if ($compiledRoute->getHostnameRegex() && !preg_match($compiledRoute->getHostnameRegex(), $this->context->getHost(), $hostnameMatches)) {
$hostMatches = array();
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
continue;
}
@ -145,7 +145,7 @@ class UrlMatcher implements UrlMatcherInterface
continue;
}
return $this->getAttributes($route, $name, array_replace($matches, $hostnameMatches));
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches));
}
}

View File

@ -29,7 +29,7 @@ class Route implements \Serializable
/**
* @var string
*/
private $hostname = '';
private $host = '';
/**
* @var array
@ -72,19 +72,19 @@ class Route implements \Serializable
* @param array $defaults An array of default parameter values
* @param array $requirements An array of requirements for parameters (regexes)
* @param array $options An array of options
* @param string $hostname The hostname pattern to match
* @param string $host The host pattern to match
* @param string|array $schemes A required URI scheme or an array of restricted schemes
* @param string|array $methods A required HTTP method or an array of restricted methods
*
* @api
*/
public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $hostname = '', $schemes = array(), $methods = array())
public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array())
{
$this->setPath($path);
$this->setDefaults($defaults);
$this->setRequirements($requirements);
$this->setOptions($options);
$this->setHostname($hostname);
$this->setHost($host);
// The conditions make sure that an initial empty $schemes/$methods does not override the corresponding requirement.
// They can be removed when the BC layer is removed.
if ($schemes) {
@ -99,7 +99,7 @@ class Route implements \Serializable
{
return serialize(array(
'path' => $this->path,
'hostname' => $this->hostname,
'host' => $this->host,
'defaults' => $this->defaults,
'requirements' => $this->requirements,
'options' => $this->options,
@ -112,7 +112,7 @@ class Route implements \Serializable
{
$data = unserialize($data);
$this->path = $data['path'];
$this->hostname = $data['hostname'];
$this->host = $data['host'];
$this->defaults = $data['defaults'];
$this->requirements = $data['requirements'];
$this->options = $data['options'];
@ -178,27 +178,27 @@ class Route implements \Serializable
}
/**
* Returns the pattern for the hostname.
* Returns the pattern for the host.
*
* @return string The hostname pattern
* @return string The host pattern
*/
public function getHostname()
public function getHost()
{
return $this->hostname;
return $this->host;
}
/**
* Sets the pattern for the hostname.
* Sets the pattern for the host.
*
* This method implements a fluent interface.
*
* @param string $pattern The hostname pattern
* @param string $pattern The host pattern
*
* @return Route The current Route instance
*/
public function setHostname($pattern)
public function setHost($pattern)
{
$this->hostname = (string) $pattern;
$this->host = (string) $pattern;
$this->compiled = null;
return $this;
@ -549,7 +549,7 @@ class Route implements \Serializable
* @return CompiledRoute A CompiledRoute instance
*
* @throws \LogicException If the Route cannot be compiled because the
* path or hostname pattern is invalid
* path or host pattern is invalid
*
* @see RouteCompiler which is responsible for the compilation process
*/

View File

@ -255,16 +255,16 @@ class RouteCollection implements \IteratorAggregate, \Countable
}
/**
* Sets the hostname pattern on all routes.
* Sets the host pattern on all routes.
*
* @param string $pattern The pattern
* @param array $defaults An array of default values
* @param array $requirements An array of requirements
*/
public function setHostname($pattern, array $defaults = array(), array $requirements = array())
public function setHost($pattern, array $defaults = array(), array $requirements = array())
{
foreach ($this->routes as $route) {
$route->setHostname($pattern);
$route->setHost($pattern);
$route->addDefaults($defaults);
$route->addRequirements($requirements);
}

View File

@ -38,22 +38,22 @@ class RouteCompiler implements RouteCompilerInterface
public static function compile(Route $route)
{
$staticPrefix = null;
$hostnameVariables = array();
$hostVariables = array();
$pathVariables = array();
$variables = array();
$tokens = array();
$regex = null;
$hostnameRegex = null;
$hostnameTokens = array();
$hostRegex = null;
$hostTokens = array();
if ('' !== $hostname = $route->getHostname()) {
$result = self::compilePattern($route, $hostname, true);
if ('' !== $host = $route->getHost()) {
$result = self::compilePattern($route, $host, true);
$hostnameVariables = $result['variables'];
$variables = array_merge($variables, $hostnameVariables);
$hostVariables = $result['variables'];
$variables = array_merge($variables, $hostVariables);
$hostnameTokens = $result['tokens'];
$hostnameRegex = $result['regex'];
$hostTokens = $result['tokens'];
$hostRegex = $result['regex'];
}
$path = $route->getPath();
@ -73,20 +73,20 @@ class RouteCompiler implements RouteCompilerInterface
$regex,
$tokens,
$pathVariables,
$hostnameRegex,
$hostnameTokens,
$hostnameVariables,
$hostRegex,
$hostTokens,
$hostVariables,
array_unique($variables)
);
}
private static function compilePattern(Route $route, $pattern, $isHostname)
private static function compilePattern(Route $route, $pattern, $isHost)
{
$tokens = array();
$variables = array();
$matches = array();
$pos = 0;
$defaultSeparator = $isHostname ? '.' : '/';
$defaultSeparator = $isHost ? '.' : '/';
// Match all variables enclosed in "{}" and iterate over them. But we only want to match the innermost variable
// in case of nested "{}", e.g. {foo{bar}}. This in ensured because \w does not match "{" or "}" itself.
@ -148,7 +148,7 @@ class RouteCompiler implements RouteCompilerInterface
// find the first optional token
$firstOptional = INF;
if (!$isHostname) {
if (!$isHost) {
for ($i = count($tokens) - 1; $i >= 0; $i--) {
$token = $tokens[$i];
if ('variable' === $token[0] && $route->hasDefault($token[3])) {

View File

@ -26,7 +26,7 @@ interface RouteCompilerInterface
* @return CompiledRoute A CompiledRoute instance
*
* @throws \LogicException If the Route cannot be compiled because the
* path or hostname pattern is invalid
* path or host pattern is invalid
*/
public static function compile(Route $route);
}

View File

@ -43,7 +43,7 @@ class RouteTest extends \PHPUnit_Framework_TestCase
array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'),
array('schemes', array('https'), 'getSchemes'),
array('methods', array('GET', 'POST'), 'getMethods'),
array('hostname', array('{locale}.example.com'), 'getHostname')
array('host', array('{locale}.example.com'), 'getHost')
);
}
}

View File

@ -77,39 +77,39 @@ RewriteCond %{REQUEST_URI} ^/test/(te\\\ st)$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz9,E=_ROUTING_param_baz:%1]
RewriteCond %{HTTP:Host} ^a\.example\.com$
RewriteRule .? - [E=__ROUTING_hostname_1:1]
RewriteRule .? - [E=__ROUTING_host_1:1]
# route1
RewriteCond %{ENV:__ROUTING_hostname_1} =1
RewriteCond %{ENV:__ROUTING_host_1} =1
RewriteCond %{REQUEST_URI} ^/route1$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route1]
# route2
RewriteCond %{ENV:__ROUTING_hostname_1} =1
RewriteCond %{ENV:__ROUTING_host_1} =1
RewriteCond %{REQUEST_URI} ^/c2/route2$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route2]
RewriteCond %{HTTP:Host} ^b\.example\.com$
RewriteRule .? - [E=__ROUTING_hostname_2:1]
RewriteRule .? - [E=__ROUTING_host_2:1]
# route3
RewriteCond %{ENV:__ROUTING_hostname_2} =1
RewriteCond %{ENV:__ROUTING_host_2} =1
RewriteCond %{REQUEST_URI} ^/c2/route3$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route3]
RewriteCond %{HTTP:Host} ^a\.example\.com$
RewriteRule .? - [E=__ROUTING_hostname_3:1]
RewriteRule .? - [E=__ROUTING_host_3:1]
# route4
RewriteCond %{ENV:__ROUTING_hostname_3} =1
RewriteCond %{ENV:__ROUTING_host_3} =1
RewriteCond %{REQUEST_URI} ^/route4$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route4]
RewriteCond %{HTTP:Host} ^c\.example\.com$
RewriteRule .? - [E=__ROUTING_hostname_4:1]
RewriteRule .? - [E=__ROUTING_host_4:1]
# route5
RewriteCond %{ENV:__ROUTING_hostname_4} =1
RewriteCond %{ENV:__ROUTING_host_4} =1
RewriteCond %{REQUEST_URI} ^/route5$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route5]
@ -118,33 +118,33 @@ RewriteCond %{REQUEST_URI} ^/route6$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route6]
RewriteCond %{HTTP:Host} ^([^\.]++)\.example\.com$
RewriteRule .? - [E=__ROUTING_hostname_5:1,E=__ROUTING_hostname_5_var1:%1]
RewriteRule .? - [E=__ROUTING_host_5:1,E=__ROUTING_host_5_var1:%1]
# route11
RewriteCond %{ENV:__ROUTING_hostname_5} =1
RewriteCond %{ENV:__ROUTING_host_5} =1
RewriteCond %{REQUEST_URI} ^/route11$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route11,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1}]
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route11,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1}]
# route12
RewriteCond %{ENV:__ROUTING_hostname_5} =1
RewriteCond %{ENV:__ROUTING_host_5} =1
RewriteCond %{REQUEST_URI} ^/route12$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route12,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1},E=_ROUTING_default_var1:val]
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route12,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_default_var1:val]
# route13
RewriteCond %{ENV:__ROUTING_hostname_5} =1
RewriteCond %{ENV:__ROUTING_host_5} =1
RewriteCond %{REQUEST_URI} ^/route13/([^/]++)$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route13,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1},E=_ROUTING_param_name:%1]
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route13,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1]
# route14
RewriteCond %{ENV:__ROUTING_hostname_5} =1
RewriteCond %{ENV:__ROUTING_host_5} =1
RewriteCond %{REQUEST_URI} ^/route14/([^/]++)$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route14,E=_ROUTING_param_var1:%{ENV:__ROUTING_hostname_5_var1},E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val]
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route14,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val]
RewriteCond %{HTTP:Host} ^c\.example\.com$
RewriteRule .? - [E=__ROUTING_hostname_6:1]
RewriteRule .? - [E=__ROUTING_host_6:1]
# route15
RewriteCond %{ENV:__ROUTING_hostname_6} =1
RewriteCond %{ENV:__ROUTING_host_6} =1
RewriteCond %{REQUEST_URI} ^/route15/([^/]++)$
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route15,E=_ROUTING_param_name:%1]

View File

@ -193,9 +193,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
}
$hostname = $this->context->getHost();
$host = $this->context->getHost();
if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
// route1
if ($pathinfo === '/route1') {
return array('_route' => 'route1');
@ -208,7 +208,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
}
if (preg_match('#^b\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^b\\.example\\.com$#s', $host, $hostMatches)) {
// route3
if ($pathinfo === '/c2/route3') {
return array('_route' => 'route3');
@ -216,7 +216,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
}
if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
// route4
if ($pathinfo === '/route4') {
return array('_route' => 'route4');
@ -224,7 +224,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
}
if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
// route5
if ($pathinfo === '/route5') {
return array('_route' => 'route5');
@ -237,33 +237,33 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
return array('_route' => 'route6');
}
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $host, $hostMatches)) {
if (0 === strpos($pathinfo, '/route1')) {
// route11
if ($pathinfo === '/route11') {
return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route11')), array ());
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
}
// route12
if ($pathinfo === '/route12') {
return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
}
// route13
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route13')), array ());
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ());
}
// route14
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
}
}
}
if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
// route15
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());

View File

@ -205,9 +205,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
}
$hostname = $this->context->getHost();
$host = $this->context->getHost();
if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
// route1
if ($pathinfo === '/route1') {
return array('_route' => 'route1');
@ -220,7 +220,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
}
if (preg_match('#^b\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^b\\.example\\.com$#s', $host, $hostMatches)) {
// route3
if ($pathinfo === '/c2/route3') {
return array('_route' => 'route3');
@ -228,7 +228,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
}
if (preg_match('#^a\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^a\\.example\\.com$#s', $host, $hostMatches)) {
// route4
if ($pathinfo === '/route4') {
return array('_route' => 'route4');
@ -236,7 +236,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
}
if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
// route5
if ($pathinfo === '/route5') {
return array('_route' => 'route5');
@ -249,33 +249,33 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
return array('_route' => 'route6');
}
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $host, $hostMatches)) {
if (0 === strpos($pathinfo, '/route1')) {
// route11
if ($pathinfo === '/route11') {
return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route11')), array ());
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
}
// route12
if ($pathinfo === '/route12') {
return $this->mergeDefaults(array_replace($hostnameMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
}
// route13
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route13')), array ());
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ());
}
// route14
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
}
}
}
if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (preg_match('#^c\\.example\\.com$#s', $host, $hostMatches)) {
// route15
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());

View File

@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<r:route id="blog_show" pattern="/blog/{slug}" hostname="{_locale}.example.com">
<r:route id="blog_show" pattern="/blog/{slug}" host="{_locale}.example.com">
<r:default key="_controller">MyBundle:Blog:show</r:default>
<requirement xmlns="http://symfony.com/schema/routing" key="slug">\w+</requirement>
<r2:requirement xmlns:r2="http://symfony.com/schema/routing" key="_locale">en|fr|de</r2:requirement>

View File

@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="blog_show" pattern="/blog/{slug}" hostname="{locale}.example.com">
<route id="blog_show" pattern="/blog/{slug}" host="{locale}.example.com">
<default key="_controller">MyBundle:Blog:show</default>
<requirement key="_method">GET</requirement>
<requirement key="locale">\w+</requirement>

View File

@ -1,7 +1,7 @@
blog_show:
pattern: /blog/{slug}
defaults: { _controller: MyBlogBundle:Blog:show }
hostname : "{locale}.example.com"
host : "{locale}.example.com"
requirements: { '_method': 'GET', 'locale': '\w+' }
options:
compiler_class: RouteCompiler

View File

@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<import resource="validpattern.xml" prefix="/{foo}" hostname="{locale}.example.com">
<import resource="validpattern.xml" prefix="/{foo}" host="{locale}.example.com">
<default key="foo">123</default>
<requirement key="foo">\d+</requirement>
<option key="foo">bar</option>

View File

@ -4,4 +4,4 @@ blog_show:
defaults: { 'foo': '123' }
requirements: { 'foo': '\d+' }
options: { 'foo': 'bar' }
hostname: "{locale}.example.com"
host: "{locale}.example.com"

View File

@ -384,21 +384,21 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
$this->getGenerator($routes)->generate('test', array('page' => 'do.t', '_format' => 'html'));
}
public function testWithHostnameDifferentFromContext()
public function testWithHostDifferentFromContext()
{
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
$this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' =>'Fabien', 'locale' => 'fr')));
}
public function testWithHostnameSameAsContext()
public function testWithHostSameAsContext()
{
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
$this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' =>'Fabien', 'locale' => 'fr')));
}
public function testWithHostnameSameAsContextAndAbsolute()
public function testWithHostSameAsContextAndAbsolute()
{
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
@ -408,7 +408,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
*/
public function testUrlWithInvalidParameterInHostname()
public function testUrlWithInvalidParameterInHost()
{
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false);
@ -417,7 +417,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
*/
public function testUrlWithInvalidParameterInHostnameWhenParamHasADefaultValue()
public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
{
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'bar'), array('foo' => 'bar'), array(), '{foo}.example.com'));
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false);
@ -426,13 +426,13 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
*/
public function testUrlWithInvalidParameterEqualsDefaultValueInHostname()
public function testUrlWithInvalidParameterEqualsDefaultValueInHost()
{
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'baz'), array('foo' => 'bar'), array(), '{foo}.example.com'));
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false);
}
public function testUrlWithInvalidParameterInHostnameInNonStrictMode()
public function testUrlWithInvalidParameterInHostInNonStrictMode()
{
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
$generator = $this->getGenerator($routes);
@ -463,7 +463,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
$routes = new RouteCollection();
$routes->add('article', new Route('/{author}/{article}/'));
$routes->add('comments', new Route('/{author}/{article}/comments'));
$routes->add('hostname', new Route('/{article}', array(), array(), array(), '{author}.example.com'));
$routes->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com'));
$routes->add('scheme', new Route('/{author}', array(), array('_scheme' => 'https')));
$routes->add('unrelated', new Route('/about'));
@ -481,7 +481,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
$this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article',
array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH)
);
$this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('hostname',
$this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host',
array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH)
);
$this->assertSame('https://example.com/app.php/bernhard', $generator->generate('scheme',

View File

@ -46,7 +46,7 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('/blog/{slug}', $route->getPath());
$this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
$this->assertEquals('GET', $route->getRequirement('_method'));
$this->assertEquals('{locale}.example.com', $route->getHostname());
$this->assertEquals('{locale}.example.com', $route->getHost());
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
}
}

View File

@ -48,7 +48,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
$this->assertEquals('GET', $route->getRequirement('_method'));
$this->assertEquals('\w+', $route->getRequirement('locale'));
$this->assertEquals('{locale}.example.com', $route->getHostname());
$this->assertEquals('{locale}.example.com', $route->getHost());
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
}
@ -63,7 +63,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
$this->assertEquals('\w+', $route->getRequirement('slug'));
$this->assertEquals('en|fr|de', $route->getRequirement('_locale'));
$this->assertEquals('{_locale}.example.com', $route->getHostname());
$this->assertEquals('{_locale}.example.com', $route->getHost());
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
}
@ -80,7 +80,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
$this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
$this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostname());
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHost());
}
/**

View File

@ -86,7 +86,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
$this->assertEquals('GET', $route->getRequirement('_method'));
$this->assertEquals('\w+', $route->getRequirement('locale'));
$this->assertEquals('{locale}.example.com', $route->getHostname());
$this->assertEquals('{locale}.example.com', $route->getHost());
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
}
@ -103,6 +103,6 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
$this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
$this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostname());
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHost());
}
}

View File

@ -163,7 +163,7 @@ class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
$collection->addCollection($collection1);
// hostname and variables
// host and variables
$collection1 = new RouteCollection();

View File

@ -155,7 +155,7 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
$collection1->add('foo4', new Route('/{foo}'));
$collection->addCollection($collection1, '/aba');
// prefix and hostname
// prefix and host
$collection1 = new RouteCollection();
@ -181,7 +181,7 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
$collection->addCollection($collection1);
// hostname and variables
// host and variables
$collection1 = new RouteCollection();

View File

@ -354,7 +354,7 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('_route' => 'bar'), $matcher->match('/new'));
}
public function testWithHostname()
public function testWithHost()
{
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo/{foo}', array(), array(), array(), '{locale}.example.com'));
@ -363,12 +363,12 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('foo' => 'bar', '_route' => 'foo', 'locale' => 'en'), $matcher->match('/foo/bar'));
}
public function testWithHostnameOnRouteCollection()
public function testWithHostOnRouteCollection()
{
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo/{foo}'));
$coll->add('bar', new Route('/bar/{foo}', array(), array(), array(), '{locale}.example.net'));
$coll->setHostname('{locale}.example.com');
$coll->setHost('{locale}.example.com');
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
$this->assertEquals(array('foo' => 'bar', '_route' => 'foo', 'locale' => 'en'), $matcher->match('/foo/bar'));
@ -380,7 +380,7 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
*/
public function testWithOutHostnameHostnameDoesNotMatch()
public function testWithOutHostHostDoesNotMatch()
{
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo/{foo}', array(), array(), array(), '{locale}.example.com'));

View File

@ -224,7 +224,7 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
$this->assertNull($collection1->get(0), '->get() does not disclose internal child RouteCollection');
}
public function testSetHostname()
public function testSetHost()
{
$collection = new RouteCollection();
$routea = new Route('/a');
@ -232,9 +232,9 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
$collection->add('a', $routea);
$collection->add('b', $routeb);
$collection->setHostname('{locale}.example.com');
$collection->setHost('{locale}.example.com');
$this->assertEquals('{locale}.example.com', $routea->getHostname());
$this->assertEquals('{locale}.example.com', $routeb->getHostname());
$this->assertEquals('{locale}.example.com', $routea->getHost());
$this->assertEquals('{locale}.example.com', $routeb->getHost());
}
}

View File

@ -181,9 +181,9 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider provideCompileWithHostnameData
* @dataProvider provideCompileWithHostData
*/
public function testCompileWithHostname($name, $arguments, $prefix, $regex, $variables, $pathVariables, $tokens, $hostnameRegex, $hostnameVariables, $hostnameTokens)
public function testCompileWithHost($name, $arguments, $prefix, $regex, $variables, $pathVariables, $tokens, $hostRegex, $hostVariables, $hostTokens)
{
$r = new \ReflectionClass('Symfony\\Component\\Routing\\Route');
$route = $r->newInstanceArgs($arguments);
@ -194,16 +194,16 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($variables, $compiled->getVariables(), $name.' (variables)');
$this->assertEquals($pathVariables, $compiled->getPathVariables(), $name.' (path variables)');
$this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)');
$this->assertEquals($hostnameRegex, str_replace(array("\n", ' '), '', $compiled->getHostnameRegex()), $name.' (hostname regex)');
$this->assertEquals($hostnameVariables, $compiled->getHostnameVariables(), $name.' (hostname variables)');
$this->assertEquals($hostnameTokens, $compiled->getHostnameTokens(), $name.' (hostname tokens)');
$this->assertEquals($hostRegex, str_replace(array("\n", ' '), '', $compiled->getHostRegex()), $name.' (host regex)');
$this->assertEquals($hostVariables, $compiled->getHostVariables(), $name.' (host variables)');
$this->assertEquals($hostTokens, $compiled->getHostTokens(), $name.' (host tokens)');
}
public function provideCompileWithHostnameData()
public function provideCompileWithHostData()
{
return array(
array(
'Route with hostname pattern',
'Route with host pattern',
array('/hello', array(), array(), array(), 'www.example.com'),
'/hello', '#^/hello$#s', array(), array(), array(
array('text', '/hello'),
@ -213,7 +213,7 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase
),
),
array(
'Route with hostname pattern and some variables',
'Route with host pattern and some variables',
array('/hello/{name}', array(), array(), array(), 'www.example.{tld}'),
'/hello', '#^/hello/(?P<name>[^/]++)$#s', array('tld', 'name'), array('name'), array(
array('variable', '/', '[^/]++', 'name'),
@ -225,7 +225,7 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase
),
),
array(
'Route with variable at beginning of hostname',
'Route with variable at beginning of host',
array('/hello', array(), array(), array(), '{locale}.example.{tld}'),
'/hello', '#^/hello$#s', array('locale', 'tld'), array(), array(
array('text', '/hello'),
@ -237,7 +237,7 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase
),
),
array(
'Route with hostname variables that has a default value',
'Route with host variables that has a default value',
array('/hello', array('locale' => 'a', 'tld' => 'b'), array(), array(), '{locale}.example.{tld}'),
'/hello', '#^/hello$#s', array('locale', 'tld'), array(), array(
array('text', '/hello'),

View File

@ -22,7 +22,7 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '__construct() takes defaults as its second argument');
$this->assertEquals(array('foo' => '\d+'), $route->getRequirements(), '__construct() takes requirements as its third argument');
$this->assertEquals('bar', $route->getOption('foo'), '__construct() takes options as its fourth argument');
$this->assertEquals('{locale}.example.com', $route->getHostname(), '__construct() takes a hostname pattern as its fifth argument');
$this->assertEquals('{locale}.example.com', $route->getHost(), '__construct() takes a host pattern as its fifth argument');
$route = new Route('/', array(), array(), array(), '', array('Https'), array('POST', 'put'));
$this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes schemes as its sixth argument and lowercases it');
@ -130,11 +130,11 @@ class RouteTest extends \PHPUnit_Framework_TestCase
);
}
public function testHostname()
public function testHost()
{
$route = new Route('/');
$route->setHostname('{locale}.example.net');
$this->assertEquals('{locale}.example.net', $route->getHostname(), '->setHostname() sets the hostname pattern');
$route->setHost('{locale}.example.net');
$this->assertEquals('{locale}.example.net', $route->getHost(), '->setHost() sets the host pattern');
}
public function testScheme()

View File

@ -62,7 +62,7 @@ class EmailValidator extends ConstraintValidator
/**
* Check DNS Records for MX type.
*
* @param string $host Hostname
* @param string $host Host
*
* @return Boolean
*/
@ -74,7 +74,7 @@ class EmailValidator extends ConstraintValidator
/**
* Check if one of MX, A or AAAA DNS RR exists.
*
* @param string $host Hostname
* @param string $host Host
*
* @return Boolean
*/