File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed
Tests/Functional/Doctrine/Phpcr Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,13 @@ protected function configureFieldsForDefaults($dynamicDefaults)
163
163
}
164
164
}
165
165
166
+ if ($ route && $ route ->getOption ('add_format_pattern ' )) {
167
+ $ defaults ['_format ' ] = array ('_format ' , 'text ' , array ('required ' => true ));
168
+ }
169
+ if ($ route && $ route ->getOption ('add_locale_pattern ' )) {
170
+ $ defaults ['_locale ' ] = array ('_format ' , 'text ' , array ('required ' => false ));
171
+ }
172
+
166
173
return $ defaults ;
167
174
}
168
175
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Cmf \Bundle \RoutingBundle \Doctrine \Phpcr ;
13
13
14
+ use PHPCR \Util \PathHelper ;
14
15
use Doctrine \Common \Persistence \ManagerRegistry ;
15
16
use Doctrine \ODM \PHPCR \DocumentManager ;
16
17
use Doctrine \ODM \PHPCR \Query \Builder \QueryBuilder ;
@@ -68,7 +69,9 @@ public function isCandidate($name)
68
69
{
69
70
foreach ($ this ->getPrefixes () as $ prefix ) {
70
71
// $name is the route document path
71
- if ($ name === $ prefix || 0 === strpos ($ name , $ prefix . '/ ' )) {
72
+ if (($ name === $ prefix || 0 === strpos ($ name , $ prefix . '/ ' ))
73
+ && PathHelper::assertValidAbsolutePath ($ name , false , false )
74
+ ) {
72
75
return true ;
73
76
}
74
77
}
@@ -113,6 +116,13 @@ public function getCandidates(Request $request)
113
116
}
114
117
}
115
118
119
+ // filter out things like double // or trailing / - this would trigger an exception on the document manager.
120
+ foreach ($ candidates as $ key => $ candidate ) {
121
+ if (! PathHelper::assertValidAbsolutePath ($ candidate , false , false )) {
122
+ unset($ candidates [$ key ]);
123
+ }
124
+ }
125
+
116
126
return $ candidates ;
117
127
}
118
128
Original file line number Diff line number Diff line change @@ -99,11 +99,17 @@ public function testGetRouteCollectionForRequestFormat()
99
99
$ this ->assertEquals (null , $ root ->getDefault ('_format ' ));
100
100
}
101
101
102
+ /**
103
+ * The root route will always be found.
104
+ */
102
105
public function testGetRouteCollectionForRequestNophpcrUrl ()
103
106
{
104
107
$ collection = $ this ->repository ->getRouteCollectionForRequest (Request::create (':/// ' ));
105
108
$ this ->assertInstanceOf ('Symfony\Component\Routing\RouteCollection ' , $ collection );
106
- $ this ->assertCount (0 , $ collection );
109
+ $ this ->assertCount (1 , $ collection );
110
+ $ routes = $ collection ->all ();
111
+ list ($ key , $ route ) = each ($ routes );
112
+ $ this ->assertEquals (self ::ROUTE_ROOT , $ key );
107
113
}
108
114
109
115
public function testGetRoutesByNames ()
@@ -113,6 +119,7 @@ public function testGetRoutesByNames()
113
119
$ routeNames = array (
114
120
self ::ROUTE_ROOT . '/testroute/noroute/child ' ,
115
121
self ::ROUTE_ROOT . '/testroute/noroute ' ,
122
+ self ::ROUTE_ROOT . '/testroute/ ' , // trailing slash is invalid for phpcr
116
123
self ::ROUTE_ROOT . '/testroute '
117
124
);
118
125
You can’t perform that action at this time.
0 commit comments