This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ public function providePath(RouteStack $routeStack)
54
54
throw new \RuntimeException (sprintf ('Method %s:%s must return an instance of DateTime. ' ));
55
55
}
56
56
57
- $ dateString = $ date ->format ($ this ->dateFormat );
58
- $ pathElements = $ this ->normalizePathElements ($ dateString );
57
+ $ string = $ date ->format ($ this ->dateFormat );
58
+ $ pathElements = $ this ->normalizePathElements ($ string , $ object );
59
59
60
60
$ routeStack ->addPathElements ($ pathElements );
61
61
}
Original file line number Diff line number Diff line change @@ -69,16 +69,16 @@ public function providePath(RouteStack $routeStack)
69
69
70
70
$ pathElements = $ object ->$ method ();
71
71
72
- $ pathElements = $ this ->normalizePathElements ($ pathElements );
72
+ $ pathElements = $ this ->normalizePathElements ($ pathElements, get_class ( $ object ). ' :: ' . $ method );
73
73
74
74
75
75
// @todo: Validate the validator service.
76
76
$ routeStack ->addPathElements ($ pathElements );
77
77
}
78
78
79
- protected function normalizePathElements ($ pathElements )
79
+ protected function normalizePathElements ($ pathElements, $ methodAsString )
80
80
{
81
- if (is_string ($ pathElements )) {
81
+ if (is_string ($ pathElements ) || ( is_object ( $ pathElements ) && method_exists ( $ pathElements , ' __toString ' )) ) {
82
82
if (substr ($ pathElements , 0 , 1 ) == '/ ' ) {
83
83
throw new \RuntimeException ('Path must not be absolute. ' );
84
84
}
@@ -88,9 +88,8 @@ protected function normalizePathElements($pathElements)
88
88
89
89
if (!is_array ($ pathElements )) {
90
90
throw new \RuntimeException (sprintf (
91
- 'FromObjectMethodProvider wants %s:%s to return an array of route names.. got "%s" ' ,
92
- get_class ($ object ),
93
- $ method ,
91
+ 'FromObjectMethodProvider wants %s to return an array of route names or a string, got "%s" ' ,
92
+ $ methodAsString ,
94
93
gettype ($ pathElements )
95
94
));
96
95
}
You can’t perform that action at this time.
0 commit comments