14
14
use Doctrine \ODM \PHPCR \DocumentManager ;
15
15
use Doctrine \ODM \PHPCR \Document \Generic ;
16
16
use Doctrine \Common \Util \ClassUtils ;
17
- use PHPCR \InvalidItemStateException ;
18
17
use Symfony \Cmf \Component \RoutingAuto \Model \AutoRouteInterface ;
19
18
use Symfony \Cmf \Component \RoutingAuto \UriContext ;
20
- use Symfony \Cmf \Bundle \RoutingBundle \Doctrine \Phpcr \RedirectRoute ;
21
19
use Symfony \Cmf \Component \RoutingAuto \AdapterInterface ;
22
- use Symfony \Cmf \Bundle \RoutingAutoBundle \Model \AutoRedirectRoute ;
23
20
24
21
/**
25
- * Adapter for PHPCR-ODM
22
+ * Adapter for PHPCR-ODM.
26
23
*
27
24
* @author Daniel Leech <[email protected] >
28
25
*/
@@ -53,7 +50,7 @@ public function __construct(DocumentManager $dm, $routeBasePath, $autoRouteFqcn
53
50
}
54
51
55
52
/**
56
- * {@inheritDoc }
53
+ * {@inheritdoc }
57
54
*/
58
55
public function getLocales ($ contentDocument )
59
56
{
@@ -65,7 +62,7 @@ public function getLocales($contentDocument)
65
62
}
66
63
67
64
/**
68
- * {@inheritDoc }
65
+ * {@inheritdoc }
69
66
*/
70
67
public function translateObject ($ contentDocument , $ locale )
71
68
{
@@ -75,15 +72,15 @@ public function translateObject($contentDocument, $locale)
75
72
}
76
73
77
74
/**
78
- * {@inheritDoc }
75
+ * {@inheritdoc }
79
76
*/
80
77
public function generateAutoRouteTag (UriContext $ uriContext )
81
78
{
82
- return $ uriContext ->getLocale () ? : self ::TAG_NO_MULTILANG ;
79
+ return $ uriContext ->getLocale () ?: self ::TAG_NO_MULTILANG ;
83
80
}
84
81
85
82
/**
86
- * {@inheritDoc }
83
+ * {@inheritdoc }
87
84
*/
88
85
public function migrateAutoRouteChildren (AutoRouteInterface $ srcAutoRoute , AutoRouteInterface $ destAutoRoute )
89
86
{
@@ -94,12 +91,12 @@ public function migrateAutoRouteChildren(AutoRouteInterface $srcAutoRoute, AutoR
94
91
$ srcAutoRouteChildren = $ srcAutoRouteNode ->getNodes ();
95
92
96
93
foreach ($ srcAutoRouteChildren as $ srcAutoRouteChild ) {
97
- $ session ->move ($ srcAutoRouteChild ->getPath (), $ destAutoRouteNode ->getPath () . '/ ' . $ srcAutoRouteChild ->getName ());
94
+ $ session ->move ($ srcAutoRouteChild ->getPath (), $ destAutoRouteNode ->getPath (). '/ ' . $ srcAutoRouteChild ->getName ());
98
95
}
99
96
}
100
97
101
98
/**
102
- * {@inheritDoc }
99
+ * {@inheritdoc }
103
100
*/
104
101
public function removeAutoRoute (AutoRouteInterface $ autoRoute )
105
102
{
@@ -110,7 +107,7 @@ public function removeAutoRoute(AutoRouteInterface $autoRoute)
110
107
}
111
108
112
109
/**
113
- * {@inheritDoc }
110
+ * {@inheritdoc }
114
111
*/
115
112
public function createAutoRoute (UriContext $ uriContext , $ contentDocument , $ autoRouteTag )
116
113
{
@@ -126,7 +123,7 @@ public function createAutoRoute(UriContext $uriContext, $contentDocument, $autoR
126
123
$ segments = preg_split ('#/# ' , $ uriContext ->getUri (), null , PREG_SPLIT_NO_EMPTY );
127
124
$ headName = array_pop ($ segments );
128
125
foreach ($ segments as $ segment ) {
129
- $ basePath .= '/ ' . $ segment ;
126
+ $ basePath .= '/ ' . $ segment ;
130
127
$ document = $ this ->dm ->find (null , $ basePath );
131
128
132
129
if (null === $ document ) {
@@ -138,7 +135,7 @@ public function createAutoRoute(UriContext $uriContext, $contentDocument, $autoR
138
135
$ parentDocument = $ document ;
139
136
}
140
137
141
- $ path = $ basePath . '/ ' . $ headName ;
138
+ $ path = $ basePath. '/ ' . $ headName ;
142
139
$ existingDocument = $ this ->dm ->find (null , $ path );
143
140
144
141
if ($ existingDocument ) {
@@ -153,7 +150,7 @@ public function createAutoRoute(UriContext $uriContext, $contentDocument, $autoR
153
150
154
151
throw new \RuntimeException (
155
152
sprintf (
156
- 'Encountered existing PHPCR-ODM document at path "%s" of class "%s", the route tree should ' .
153
+ 'Encountered existing PHPCR-ODM document at path "%s" of class "%s", the route tree should ' .
157
154
'contain only instances of AutoRouteInterface. ' ,
158
155
$ path ,
159
156
get_class ($ existingDocument )
@@ -172,7 +169,7 @@ public function createAutoRoute(UriContext $uriContext, $contentDocument, $autoR
172
169
}
173
170
174
171
/**
175
- * {@inheritDoc }
172
+ * {@inheritdoc }
176
173
*/
177
174
public function createRedirectRoute (AutoRouteInterface $ referringAutoRoute , AutoRouteInterface $ newRoute )
178
175
{
@@ -181,15 +178,15 @@ public function createRedirectRoute(AutoRouteInterface $referringAutoRoute, Auto
181
178
}
182
179
183
180
/**
184
- * {@inheritDoc }
181
+ * {@inheritdoc }
185
182
*/
186
183
public function getRealClassName ($ className )
187
184
{
188
185
return ClassUtils::getRealClass ($ className );
189
186
}
190
187
191
188
/**
192
- * {@inheritDoc }
189
+ * {@inheritdoc }
193
190
*/
194
191
public function compareAutoRouteContent (AutoRouteInterface $ autoRoute , $ contentDocument )
195
192
{
@@ -201,36 +198,37 @@ public function compareAutoRouteContent(AutoRouteInterface $autoRoute, $contentD
201
198
}
202
199
203
200
/**
204
- * {@inheritDoc }
201
+ * {@inheritdoc }
205
202
*/
206
203
public function getReferringAutoRoutes ($ contentDocument )
207
204
{
208
- return $ this ->dm ->getReferrers ($ contentDocument , null , null , null , 'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface ' );
205
+ return $ this ->dm ->getReferrers ($ contentDocument , null , null , null , 'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface ' );
209
206
}
210
207
211
208
/**
212
- * {@inheritDoc }
209
+ * {@inheritdoc }
213
210
*/
214
211
public function findRouteForUri ($ uri , UriContext $ uriContext )
215
212
{
216
213
return $ this ->dm ->find (
217
- 'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface ' ,
214
+ 'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface ' ,
218
215
$ this ->getPathFromUri ($ uri )
219
216
);
220
217
}
221
218
222
219
private function getPathFromUri ($ uri )
223
220
{
224
- return $ this ->baseRoutePath . $ uri ;
221
+ return $ this ->baseRoutePath . $ uri ;
225
222
}
226
223
227
224
/**
228
225
* Convert the given generic document to an auto route document.
229
226
*
230
227
* @param Generic $document
231
- * @param object $contentDocument
232
- * @param string $autoRouteTag
233
- * @param string $routeType
228
+ * @param object $contentDocument
229
+ * @param string $autoRouteTag
230
+ * @param string $routeType
231
+ *
234
232
* @return AutoRouteInterface
235
233
*/
236
234
private function migrateGenericToAutoRoute (Generic $ document , $ contentDocument , $ autoRouteTag , $ routeType )
@@ -246,7 +244,7 @@ private function migrateGenericToAutoRoute(Generic $document, $contentDocument,
246
244
if (!$ autoRoute instanceof $ autoRouteClassName ) {
247
245
throw new \RuntimeException (
248
246
sprintf (
249
- 'Failed to migrate existing, non-managed, PHPCR node at "%s" to a managed document implementing ' .
247
+ 'Failed to migrate existing, non-managed, PHPCR node at "%s" to a managed document implementing ' .
250
248
'the AutoRouteInterface. It is an instance of "%s". ' ,
251
249
$ document ->getId (),
252
250
get_class ($ autoRoute )
0 commit comments