From 94f6116f42834b49f1237fd465283661b509200f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 21 Jan 2013 17:57:28 +0100 Subject: [PATCH] renamed hostname to host in the routing system (closes #6775) As explained in #6775, this has been done for the following reasons: 1. It's also Request::getHost() 2. The term hostname has been obsoleted in http://tools.ietf.org/html/rfc3986#appendix-D.2 and uses the host only 3. hostname in the RFC was defined as the registered domain name, but we probably also want to match IP-Adresses with the pattern which is the host = IP-literal / IPv4address / reg-name for. --- .../Command/RouterDebugCommand.php | 20 ++++----- .../Bundle/FrameworkBundle/Routing/Router.php | 4 +- .../Tests/Routing/RouterTest.php | 6 +-- .../Component/Routing/Annotation/Route.php | 10 ++--- .../Component/Routing/CompiledRoute.php | 42 +++++++++---------- .../Generator/Dumper/PhpGeneratorDumper.php | 6 +-- .../Routing/Generator/UrlGenerator.php | 10 ++--- .../Generator/UrlGeneratorInterface.php | 8 ++-- .../Routing/Loader/AnnotationClassLoader.php | 16 +++---- .../Routing/Loader/XmlFileLoader.php | 8 ++-- .../Routing/Loader/YamlFileLoader.php | 12 +++--- .../Loader/schema/routing/routing-1.0.xsd | 4 +- .../Matcher/Dumper/ApacheMatcherDumper.php | 42 +++++++++---------- .../Matcher/Dumper/PhpMatcherDumper.php | 42 +++++++++---------- .../Component/Routing/Matcher/UrlMatcher.php | 6 +-- src/Symfony/Component/Routing/Route.php | 30 ++++++------- .../Component/Routing/RouteCollection.php | 6 +-- .../Component/Routing/RouteCompiler.php | 30 ++++++------- .../Routing/RouteCompilerInterface.php | 2 +- .../Routing/Tests/Annotation/RouteTest.php | 2 +- .../Tests/Fixtures/dumper/url_matcher1.apache | 40 +++++++++--------- .../Tests/Fixtures/dumper/url_matcher1.php | 22 +++++----- .../Tests/Fixtures/dumper/url_matcher2.php | 22 +++++----- .../Tests/Fixtures/namespaceprefix.xml | 2 +- .../Routing/Tests/Fixtures/validpattern.xml | 2 +- .../Routing/Tests/Fixtures/validpattern.yml | 2 +- .../Routing/Tests/Fixtures/validresource.xml | 2 +- .../Routing/Tests/Fixtures/validresource.yml | 2 +- .../Tests/Generator/UrlGeneratorTest.php | 18 ++++---- .../Tests/Loader/PhpFileLoaderTest.php | 2 +- .../Tests/Loader/XmlFileLoaderTest.php | 6 +-- .../Tests/Loader/YamlFileLoaderTest.php | 4 +- .../Dumper/ApacheMatcherDumperTest.php | 2 +- .../Matcher/Dumper/PhpMatcherDumperTest.php | 4 +- .../Routing/Tests/Matcher/UrlMatcherTest.php | 8 ++-- .../Routing/Tests/RouteCollectionTest.php | 8 ++-- .../Routing/Tests/RouteCompilerTest.php | 20 ++++----- .../Component/Routing/Tests/RouteTest.php | 8 ++-- 38 files changed, 240 insertions(+), 240 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 79e4439420..a16a392054 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -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, 'Name', 'Method', 'Hostname', 'Pattern')); + $format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHost + 19).'s %s'; + $output->writeln(sprintf($format1, 'Name', 'Method', 'Host', 'Pattern')); 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('Name %s', $name)); $output->writeln(sprintf('Pattern %s', $route->getPath())); - $output->writeln(sprintf('Hostname %s', $hostname)); + $output->writeln(sprintf('Host %s', $host)); $output->writeln(sprintf('Class %s', get_class($route))); $defaults = ''; diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index 460d8f353f..5777479d4d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -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())); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 28aaa8b781..fa297652b9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -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() ); } diff --git a/src/Symfony/Component/Routing/Annotation/Route.php b/src/Symfony/Component/Routing/Annotation/Route.php index a43cce2e71..abdbea27c6 100644 --- a/src/Symfony/Component/Routing/Annotation/Route.php +++ b/src/Symfony/Component/Routing/Annotation/Route.php @@ -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) diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index 1ccad3c22a..7878455427 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -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; } } diff --git a/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php index d50cd9979b..8aadde5274 100644 --- a/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ b/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php @@ -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; } diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index 76d2852d02..f15d65b2a5 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -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. diff --git a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php index c38f310227..8e3b2778b9 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php @@ -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. diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index 66ce367617..9831d85a09 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -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); diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 983c080211..a50da26648 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -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); diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 47c483d472..a3cf2f1c00 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -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); diff --git a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd index 7fbf94081b..bbd918c3f5 100644 --- a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd @@ -48,7 +48,7 @@ - + @@ -59,7 +59,7 @@ - + diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php index e46b506b10..804da19d54 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php @@ -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"; diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index 8fb232ea09..dc17ffbe98 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -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)); diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index c0fea2d7e7..db18ec4e7b 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -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)); } } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index e35cf034c1..478d4e12a0 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -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 */ diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index f1a67e7b90..e53606da5f 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -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); } diff --git a/src/Symfony/Component/Routing/RouteCompiler.php b/src/Symfony/Component/Routing/RouteCompiler.php index 4d6645fc58..25e4029f04 100644 --- a/src/Symfony/Component/Routing/RouteCompiler.php +++ b/src/Symfony/Component/Routing/RouteCompiler.php @@ -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])) { diff --git a/src/Symfony/Component/Routing/RouteCompilerInterface.php b/src/Symfony/Component/Routing/RouteCompilerInterface.php index 36e131c2ff..e6f8ee6dea 100644 --- a/src/Symfony/Component/Routing/RouteCompilerInterface.php +++ b/src/Symfony/Component/Routing/RouteCompilerInterface.php @@ -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); } diff --git a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index 53183e9581..b58869f7af 100644 --- a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -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') ); } } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache index 4b9c11d4d0..26a561cc91 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache @@ -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] diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index bb4e623ed9..e5f7665c81 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -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[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) { + if (preg_match('#^(?P[^\\.]++)\\.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[^/]++)$#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[^/]++)$#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[^/]++)$#s', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index 2bd38122a0..ad157909b8 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -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[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) { + if (preg_match('#^(?P[^\\.]++)\\.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[^/]++)$#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[^/]++)$#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[^/]++)$#s', $pathinfo, $matches)) { return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml b/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml index 118cf70074..79ec6e9169 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml @@ -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"> - + MyBundle:Blog:show \w+ en|fr|de diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml index 198d15d4b7..eb3aea78b6 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml @@ -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"> - + MyBundle:Blog:show GET \w+ diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml index 4d9f1c474d..d78a3e44e7 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml @@ -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 diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml index 803d8f2eed..dd457dc821 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml @@ -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"> - + 123 \d+ diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml index b1de7ebbfc..1f5644e04b 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml @@ -4,4 +4,4 @@ blog_show: defaults: { 'foo': '123' } requirements: { 'foo': '\d+' } options: { 'foo': 'bar' } - hostname: "{locale}.example.com" + host: "{locale}.example.com" diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 7c4a119b85..0728503b06 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -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', diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index 109ade1183..6cb2456852 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php @@ -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')); } } diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 04379a80c7..e40468247d 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -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()); } /** diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index e7af00de24..bb055de4e7 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -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()); } } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php index e72976f047..da72d6b3a9 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php @@ -163,7 +163,7 @@ class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase $collection->addCollection($collection1); - // hostname and variables + // host and variables $collection1 = new RouteCollection(); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index e04310cc9a..4764df617d 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -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(); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index d980e4e53a..fee6fe2b6f 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -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')); diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index f0b542c354..65f9967e6a 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -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()); } } diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index 42d8976455..430cae7c7c 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -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[^/]++)$#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'), diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index 954dab41d6..31f1066fed 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -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()