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