8000 [FrameworkBundle] Added hostnamePattern to the router:debug command · sun/symfony@d902e9d · GitHub
[go: up one dir, main page]

Skip to content

Commit d902e9d

Browse files
committed
[FrameworkBundle] Added hostnamePattern to the router:debug command
1 parent aee0336 commit d902e9d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
9292
? implode(', ', $requirements['_method']) : $requirements['_method']
9393
)
9494
: 'ANY';
95-
$hostname = '' !== $route->getHostnamePattern()
96-
? $route->getHostnamePattern() : 'ANY';
97-
95+
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
9896
$maxName = max($maxName, strlen($name));
9997
$maxMethod = max($maxMethod, strlen($method));
10098
$maxHostname = max($maxHostname, strlen($hostname));
@@ -111,8 +109,7 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
111109
? implode(', ', $requirements['_method']) : $requirements['_method']
112110
)
113111
: 'ANY';
114-
$hostname = '' !== $route->getHostnamePattern()
115-
? $route->getHostnamePattern() : 'ANY';
112+
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
116113
$output->writeln(sprintf($format, $name, $method, $hostname, $route->getPattern()));
117114
}
118115
}
@@ -127,10 +124,13 @@ protected function outputRoute(OutputInterface $output, $name)
127124
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
128125
}
129126

127+
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
128+
130129
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));
131130

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

136136
$defaults = '';
@@ -139,24 +139,25 @@ protected function outputRoute(OutputInterface $output, $name)
139139
foreach ($d as $name => $value) {
140140
$defaults .= ($defaults ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value);
141141
}
142-
$output->writeln(sprintf('<comment>Defaults</comment> %s', $defaults));
142+
$output->writeln(sprintf('<comment>Defaults</comment> %s', $defaults));
143143

144144
$requirements = '';
145145
$r = $route->getRequirements();
146146
ksort($r);
147147
foreach ($r as $name => $value) {
148148
$requirements .= ($requirements ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value);
149149
}
150-
$output->writeln(sprintf('<comment>Requirements</comment> %s', $requirements));
150+
$requirements = '' !== $requirements ? $route->getHostnamePattern() : 'NONE';
151+
$output->writeln(sprintf('<comment>Requirements</comment> %s', $requirements));
151152

152153
$options = '';
153154
$o = $route->getOptions();
154155
ksort($o);
155156
foreach ($o as $name => $value) {
156157
$options .= ($options ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value);
157158
}
158-
$output->writeln(sprintf('<comment>Options</comment> %s', $options));
159-
$output->write('<comment>Regex</comment> ');
159+
$output->writeln(sprintf('<comment>Options</comment> %s', $options));
160+
$output->write('<comment>Regex</comment> ');
160161
$output->writeln(preg_replace('/^ /', '', preg_replace('/^/m', ' ', $route->compile()->getRegex())), OutputInterface::OUTPUT_RAW);
161162
}
162163

0 commit comments

Comments
 (0)
0