Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b357caf

Browse filesBrowse files
committed
[Routing] renamed hostname pattern to just hostname
1 parent e803f46 commit b357caf
Copy full SHA for b357caf
Expand file treeCollapse file tree

23 files changed

+94
-95
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
9292
? implode(', ', $requirements['_method']) : $requirements['_method']
9393
)
9494
: 'ANY';
95-
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
95+
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
9696
$maxName = max($maxName, strlen($name));
9797
$maxMethod = max($maxMethod, strlen($method));
9898
$maxHostname = max($maxHostname, strlen($hostname));
@@ -109,7 +109,7 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
109109
? implode(', ', $requirements['_method']) : $requirements['_method']
110110
)
111111
: 'ANY';
112-
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
112+
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
113113
$output->writeln(sprintf($format, $name, $method, $hostname, $route->getPattern()));
114114
}
115115
}
@@ -124,14 +124,14 @@ protected function outputRoute(OutputInterface $output, $name)
124124
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
125125
}
126126

127-
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
127+
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
128128

129129
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));
130130

131-
$output->writeln(sprintf('<comment>Name</comment> %s', $name));
132-
$output->writeln(sprintf('<comment>Pattern</comment> %s', $route->getPattern()));
133-
$output->writeln(sprintf('<comment>HostnamePattern</comment> %s', $hostname));
134-
$output->writeln(sprintf('<comment>Class</comment> %s', get_class($route)));
131+
$output->writeln(sprintf('<comment>Name</comment> %s', $name));
132+
$output->writeln(sprintf('<comment>Pattern</comment> %s', $route->getPattern()));
133+
$output->writeln(sprintf('<comment>Hostname</comment> %s', $hostname));
134+
$output->writeln(sprintf('<comment>Class</comment> %s', get_class($route)));
135135

136136
$defaults = '';
137137
$d = $route->getDefaults();

‎src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function warmUp($cacheDir)
7878
* - the route defaults,
7979
* - the route requirements,
8080
* - the route pattern.
81-
* - the route hostnamePattern.
81+
* - the route hostname.
8282
*
8383
* @param RouteCollection $collection
8484
*/
@@ -94,7 +94,7 @@ private function resolveParameters(RouteCollection $collection)
9494
}
9595

9696
$route->setPattern($this->resolve($route->getPattern()));
97-
$route->setHostnamePattern($this->resolve($route->getHostnamePattern()));
97+
$route->setHostname($this->resolve($route->getHostname()));
9898
}
9999
}
100100

‎src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ public function testPatternPlaceholders()
117117
);
118118
}
119119

120-
public function testHostnamePatternPlaceholders()
120+
public function testHostnamePlaceholders()
121121
{
122122
$routes = new RouteCollection();
123123

124124
$route = new Route('foo');
125-
$route->setHostnamePattern('/before/%parameter.foo%/after/%%unescaped%%');
125+
$route->setHostname('/before/%parameter.foo%/after/%%unescaped%%');
126126

127127
$routes->add('foo', $route);
128128

@@ -136,7 +136,7 @@ public function testHostnamePatternPlaceholders()
136136

137137
$this->assertEquals(
138138
'/before/foo/after/%unescaped%',
139-
$route->getHostnamePattern()
139+
$route->getHostname()
140140
);
141141
}
142142

‎src/Symfony/Component/Routing/Annotation/Route.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Annotation/Route.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Route
2525
private $requirements;
2626
private $options;
2727
private $defaults;
28-
private $hostnamePattern;
28+
private $hostname;
2929

3030
/**
3131
* Constructor.
@@ -62,14 +62,14 @@ public function getPattern()
6262
return $this->pattern;
6363
}
6464

65-
public function setHostnamePattern($pattern)
65+
public function setHostname($pattern)
6666
{
67-
$this->hostnamePattern = $pattern;
67+
$this->hostname = $pattern;
6868
}
6969

70-
public function getHostnamePattern()
70+
public function getHostname()
7171
{
72-
return $this->hostnamePattern;
72+
return $this->hostname;
7373
}
7474

7575
public function setName($name)

‎src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public function load($class, $type = null)
108108
}
109109

110110
$globals = array(
111-
'pattern' => '',
112-
'requirements' => array(),
113-
'options' => array(),
114-
'defaults' => array(),
115-
'hostname_pattern' => '',
111+
'pattern' => '',
112+
'requirements' => array(),
113+
'options' => array(),
114+
'defaults' => array(),
115+
'hostname' => '',
116116
);
117117

118118
$class = new \ReflectionClass($class);
@@ -137,8 +137,8 @@ public function load($class, $type = null)
137137
$globals['defaults'] = $annot->getDefaults();
138138
}
139139

140-
if (null !== $annot->getHostnamePattern()) {
141-
$globals['hostname_pattern'] = $annot->getHostnamePattern();
140+
if (null !== $annot->getHostname()) {
141+
$globals['hostname'] = $annot->getHostname();
142142
}
143143
}
144144

@@ -173,12 +173,12 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
173173
$requirements = array_replace($globals['requirements'], $annot->getRequirements());
174174
$options = array_replace($globals['options'], $annot->getOptions());
175175

176-
$hostnamePattern = $annot->getHostnamePattern();
177-
if (null === $hostnamePattern) {
178-
$hostnamePattern = $globals['hostname_pattern'];
176+
$hostname = $annot->getHostname();
177+
if (null === $hostname) {
178+
$hostname = $globals['hostname'];
179179
}
180180

181-
$route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options, $hostnamePattern);
181+
$route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options, $hostname);
182182

183183
$this->configureRoute($route, $class, $method, $annot);
184184

‎src/Symfony/Component/Routing/Loader/XmlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/XmlFileLoader.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $p
121121

122122
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
123123

124-
$route = new Route($node->getAttribute('pattern'), $defaults, $requirements, $options, $node->getAttribute('hostname-pattern'), $schemes, $methods);
124+
$route = new Route($node->getAttribute('pattern'), $defaults, $requirements, $options, $node->getAttribute('hostname'), $schemes, $methods);
125125
$collection->add($id, $route);
126126
}
127127

@@ -143,7 +143,7 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
143143

144144
$type = $node->getAttribute('type');
145145
$prefix = $node->getAttribute('prefix');
146-
$hostnamePattern = $node->hasAttribute('hostname-pattern') ? $node->getAttribute('hostname-pattern') : null;
146+
$hostname = $node->hasAttribute('hostname') ? $node->getAttribute('hostname') : null;
147147
$schemes = $node->hasAttribute('schemes') ? array_filter(explode(' ', $node->getAttribute('schemes'))) : null;
148148
$methods = $node->hasAttribute('methods') ? array_filter(explode(' ', $node->getAttribute('methods'))) : null;
149149

@@ -154,8 +154,8 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
154154
$subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file);
155155
/* @var $subCollection RouteCollection */
156156
$subCollection->addPrefix($prefix);
157-
if (null !== $hostnamePattern) {
158-
$subCollection->setHostnamePattern($hostnamePattern);
157+
if (null !== $hostname) {
158+
$subCollection->setHostname($hostname);
159159
}
160160
if (null !== $schemes) {
161161
$subCollection->setSchemes($schemes);

‎src/Symfony/Component/Routing/Loader/YamlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/YamlFileLoader.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class YamlFileLoader extends FileLoader
2929
{
3030
private static $availableKeys = array(
31-
'resource', 'type', 'prefix', 'pattern', 'hostname_pattern', 'schemes', 'methods', 'defaults', 'requirements', 'options',
31+
'resource', 'type', 'prefix', 'pattern', 'hostname', 'schemes', 'methods', 'defaults', 'requirements', 'options',
3232
);
3333

3434
/**
@@ -98,11 +98,11 @@ protected function parseRoute(RouteCollection $collection, $name, array $config,
9898
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
9999
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
100100
$options = isset($config['options']) ? $config['options'] : array();
101-
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : '';
101+
$hostname = isset($config['hostname']) ? $config['hostname'] : '';
102102
$schemes = isset($config['schemes']) ? $config['schemes'] : array();
103103
$methods = isset($config['methods']) ? $config['methods'] : array();
104104

105-
$route = new Route($config['pattern'], $defaults, $requirements, $options, $hostnamePattern, $schemes, $methods);
105+
$route = new Route($config['pattern'], $defaults, $requirements, $options, $hostname, $schemes, $methods);
106106

107107
$collection->add($name, $route);
108108
}
@@ -122,7 +122,7 @@ protected function parseImport(RouteCollection $collection, array $config, $path
122122
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
123123
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
124124
$options = isset($config['options']) ? $config['options'] : array();
125-
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null;
125+
$hostname = isset($config['hostname']) ? $config['hostname'] : null;
126126
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
127127
$methods = isset($config['methods']) ? $config['methods'] : null;
128128

@@ -131,8 +131,8 @@ protected function parseImport(RouteCollection $collection, array $config, $path
131131
$subCollection = $this->import($config['resource'], $type, false, $file);
132132
/* @var $subCollection RouteCollection */
133133
$subCollection->addPrefix($prefix);
134-
if (null !== $hostnamePattern) {
135-
$subCollection->setHostnamePattern($hostnamePattern);
134+
if (null !== $hostname) {
135+
$subCollection->setHostname($hostname);
136136
}
137137
if (null !== $schemes) {
138138
$subCollection->setSchemes($schemes);

‎src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<xsd:attribute name="id" type="xsd:string" use="required" />
4949
<xsd:attribute name="pattern" type="xsd:string" use="required" />
50-
<xsd:attribute name="hostname-pattern" type="xsd:string" />
50+
<xsd:attribute name="hostname" type="xsd:string" />
5151
<xsd:attribute name="schemes" type="stringlist" />
5252
<xsd:attribute name="methods" type="stringlist" />
5353
</xsd:complexType>
@@ -58,7 +58,7 @@
5858
<xsd:attribute name="resource" type="xsd:string" use="required" />
5959
<xsd:attribute name="type" type="xsd:string" />
6060
<xsd:attribute name="prefix" type="xsd:string" />
61-
<xsd:attribute name="hostname-pattern" type="xsd:string" />
61+
<xsd:attribute name="hostname" type="xsd:string" />
6262
<xsd:attribute name="schemes" type="stringlist" />
6363
<xsd:attribute name="methods" type="stringlist" />
6464
</xsd:complexType>

‎src/Symfony/Component/Routing/Route.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Route.php
+21-22Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Route implements \Serializable
2929
/**
3030
* @var string
3131
*/
32-
private $hostnamePattern = '';
32+
private $hostname = '';
3333

3434
/**
3535
* @var array
@@ -70,24 +70,23 @@ class Route implements \Serializable
7070
*
7171
* * compiler_class: A class name able to compile this route instance (RouteCompiler by default)
7272
*
73-
* @param string $pattern The path pattern to match
74-
* @param array $defaults An array of default parameter values
75-
* @param array $requirements An array of requirements for parameters (regexes)
76-
* @param array $options An array of options
77-
* @param string $hostnamePattern The hostname pattern to match
78-
* @param string|array $schemes A required URI scheme or an array of restricted schemes
79-
* @param string|array $methods A required HTTP method or an array of restricted methods
73+
* @param string $pattern The path pattern to match
74+
* @param array $defaults An array of default parameter values
75+
* @param array $requirements An array of requirements for parameters (regexes)
76+
* @param array $options An array of options
77+
* @param string $hostname The hostname pattern to match
78+
* @param string|array $schemes A required URI scheme or an array of restricted schemes
79+
* @param string|array $methods A required HTTP method or an array of restricted methods
8080
*
8181
* @api
8282
*/
83-
public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array(),
84-
$hostnamePattern = '', $schemes = array(), $methods = array())
83+
public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array(), $hostname = '', $schemes = array(), $methods = array())
8584
{
8685
$this->setPattern($pattern);
8786
$this->setDefaults($defaults);
8887
$this->setRequirements($requirements);
8988
$this->setOptions($options);
90-
$this->setHostnamePattern($hostnamePattern);
89+
$this->setHostname($hostname);
9190
// The conditions make sure that an initial empty $schemes/$methods does not override the corresponding requirement.
9291
// They can be removed when the BC layer is removed.
9392
if ($schemes) {
@@ -101,21 +100,21 @@ public function __construct($pattern, array $defaults = array(), array $requirem
101100
public function serialize()
102101
{
103102
return serialize(array(
104-
'pattern' => $this->pattern,
105-
'hostnamePattern' => $this->hostnamePattern,
106-
'defaults' => $this->defaults,
103+
'pattern' => $this->pattern,
104+
'hostname' => $this->hostname,
105+
'defaults' => $this->defaults,
107106
'requirements' => $this->requirements,
108-
'options' => $this->options,
109-
'schemes' => $this->schemes,
110-
'methods' => $this->methods,
107+
'options' => $this->options,
108+
'schemes' => $this->schemes,
109+
'methods' => $this->methods,
111110
));
112111
}
113112

114113
public function unserialize($data)
115114
{
116115
$data = unserialize($data);
117116
$this->pattern = $data['pattern'];
118-
$this->hostnamePattern = $data['hostnamePattern'];
117+
$this->hostname = $data['hostname'];
119118
$this->defaults = $data['defaults'];
120119
$this->requirements = $data['requirements'];
121120
$this->options = $data['options'];
@@ -157,19 +156,19 @@ public function setPattern($pattern)
157156
*
158157
* @return string The pattern
159158
*/
160-
public function getHostnamePattern()
159+
public function getHostname()
161160
{
162-
return $this->hostnamePattern;
161+
return $this->hostname;
163162
}
164163

165164
/**
166165
* Sets the hostname pattern.
167166
*
168167
* @param string $pattern The pattern
169168
*/
170-
public function setHostnamePattern($pattern)
169+
public function setHostname($pattern)
171170
{
172-
$this->hostnamePattern = (string) $pattern;
171+
$this->hostname = (string) $pattern;
173172
$this->compiled = null;
174173

175174
return $this;

‎src/Symfony/Component/Routing/RouteCollection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/RouteCollection.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ public function getPrefix()
261261
* @param array $defaults An array of default values
262262
* @param array $requirements An array of requirements
263263
*/
264-
public function setHostnamePattern($pattern, array $defaults = array(), array $requirements = array())
264+
public function setHostname($pattern, array $defaults = array(), array $requirements = array())
265265
{
266266
foreach ($this->routes as $route) {
267-
$route->setHostnamePattern($pattern);
267+
$route->setHostname($pattern);
268268
$route->addDefaults($defaults);
269269
$route->addRequirements($requirements);
270270
}

‎src/Symfony/Component/Routing/RouteCompiler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/RouteCompiler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function compile(Route $route)
4646
$hostnameRegex = null;
4747
$hostnameTokens = array();
4848

49-
if ('' !== $hostnamePattern = $route->getHostnamePattern()) {
50-
$result = $this->compilePattern($route, $hostnamePattern, true);
49+
if ('' !== $hostname = $route->getHostname()) {
50+
$result = $this->compilePattern($route, $hostname, true);
5151

5252
$hostnameVariables = $result['variables'];
5353
$variables = array_merge($variables, $hostnameVariables);

‎src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getValidParameters()
4040
array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'),
4141
array('name', 'blog_index', 'getName'),
4242
array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'),
43-
array('hostname_pattern', array('{locale}.example.com'), 'getHostnamePattern')
43+
array('hostname', array('{locale}.example.com'), 'getHostname')
4444
);
4545
}
4646
}

‎src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<r:route id="blog_show" pattern="/blog/{slug}" hostname-pattern="{_locale}.example.com">
7+
<r:route id="blog_show" pattern="/blog/{slug}" hostname="{_locale}.example.com">
88
<r:default key="_controller">MyBundle:Blog:show</r:default>
99
<requirement xmlns="http://symfony.com/schema/routing" key="slug">\w+</requirement>
1010
<r2:requirement xmlns:r2="http://symfony.com/schema/routing" key="_locale">en|fr|de</r2:requirement>

‎src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<route id="blog_show" pattern="/blog/{slug}" hostname-pattern="{locale}.example.com">
7+
<route id="blog_show" pattern="/blog/{slug}" hostname="{locale}.example.com">
88
<default key="_controller">MyBundle:Blog:show</default>
99
<requirement key="_method">GET</requirement>
1010
<requirement key="locale">\w+</requirement>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.