@@ -83,29 +83,29 @@ protected function outputRoutes(OutputInterface $output, $routes)
83
83
{
84
84
$ output ->writeln ($ this ->getHelper ('formatter ' )->formatSection ('router ' , 'Current routes ' ));
85
85
86
- $ maxName = 4 ;
87
- $ maxMethod = 6 ;
86
+ $ maxName = strlen ('name ' );
87
+ $ maxMethod = strlen ('method ' );
88
+ $ maxHostname = strlen ('hostname ' );
89
+
88
90
foreach ($ routes as $ name => $ route ) {
89
91
$ requirements = $ route ->getRequirements ();
90
92
$ method = isset ($ requirements ['_method ' ]) ? strtoupper (is_array ($ requirements ['_method ' ]) ? implode (', ' , $ requirements ['_method ' ]) : $ requirements ['_method ' ]) : 'ANY ' ;
93
+ $ hostname = null !== $ route ->getHostnamePattern () ? $ route ->getHostnamePattern () : 'ANY ' ;
91
94
92
- if (strlen ($ name ) > $ maxName ) {
93
- $ maxName = strlen ($ name );
94
- }
95
-
96
- if (strlen ($ method ) > $ maxMethod ) {
97
- $ maxMethod = strlen ($ method );
98
- }
95
+ $ maxName = max ($ maxName , strlen ($ name ));
96
+ $ maxMethod = max ($ maxMethod , strlen ($ method ));
97
+ $ maxHostname = max ($ maxHostname , strlen ($ hostname ));
99
98
}
100
- $ format = '%- ' .$ maxName .'s %- ' .$ maxMethod .'s %s ' ;
99
+ $ format = '%- ' .$ maxName .'s %- ' .$ maxMethod .'s %- ' . $ maxHostname . ' s % s ' ;
101
100
102
101
// displays the generated routes
103
- $ format1 = '%- ' .($ maxName + 19 ).'s %- ' .($ maxMethod + 19 ).'s %s ' ;
104
- $ output ->writeln (sprintf ($ format1 , '<comment>Name</comment> ' , '<comment>Method</comment> ' , '<comment>Pattern</comment> ' ));
102
+ $ format1 = '%- ' .($ maxName + 19 ).'s %- ' .($ maxMethod + 19 ).'s %- ' .( $ maxHostname + 19 ). ' s % s ' ;
103
+ $ output ->writeln (sprintf ($ format1 , '<comment>Name</comment> ' , '<comment>Method</comment> ' , '<comment>Hostname</comment> ' , ' <comment> Pattern</comment> ' ));
105
104
foreach ($ routes as $ name => $ route ) {
106
105
$ requirements = $ route ->getRequirements ();
107
106
$ method = isset ($ requirements ['_method ' ]) ? strtoupper (is_array ($ requirements ['_method ' ]) ? implode (', ' , $ requirements ['_method ' ]) : $ requirements ['_method ' ]) : 'ANY ' ;
108
- $ output ->writeln (sprintf ($ format , $ name , $ method , $ route ->getPattern ()));
107
+ $ hostname = null !== $ route ->getHostnamePattern () ? $ route ->getHostnamePattern () : 'ANY ' ;
108
+ $ output ->writeln (sprintf ($ format , $ name , $ method , $ hostname , $ route ->getPattern ()));
109
109
}
110
110
}
111
111
0 commit comments