@@ -62,30 +62,39 @@ public function supports($resource, $type = null)
62
62
* Create route for REST action
63
63
*
64
64
* @param RouteCollection $collection
65
- * @param string $document
66
- * @param array $endpoint
67
- * @param string $version
65
+ * @param string $document
66
+ * @param array $endpoint
67
+ * @param string $version
68
68
*/
69
69
private function processRestRoute (
70
70
$ collection ,
71
71
$ document ,
72
72
$ endpoint ,
73
73
$ version = 'v1 '
74
74
) {
75
+
75
76
$ defaults = [
76
77
'_documentId ' => null ,
77
78
'_endpoint ' => $ endpoint ,
78
79
'_version ' => $ version ,
79
80
'repository ' => $ endpoint ['repository ' ],
80
81
];
81
82
82
- $ pattern = $ version. '/ ' . sprintf ('%s/{documentId} ' , strtolower ($ document ));
83
+ $ pattern = $ version . '/ ' . sprintf ('%s/{documentId} ' , strtolower ($ document ));
83
84
84
85
if ($ endpoint ['batch ' ]) {
85
86
$ defaults ['_controller ' ] = 'ONGRApiBundle:Batch:Process ' ;
86
- $ batchPattern = $ version. '/ ' . sprintf ('%s ' , strtolower ($ document )) . '/_batch ' ;
87
+ $ batchPattern = $ version . '/ ' . sprintf ('%s ' , strtolower ($ document )) . '/_batch ' ;
87
88
$ name = strtolower (sprintf ('ongr_api_%s_%s_%s ' , $ version , $ document , Request::METHOD_POST ));
88
- $ collection ->add ($ name .'_batch ' , new Route ($ batchPattern , $ defaults , [], [], "" , [], [Request::METHOD_POST ]));
89
+ $ collection ->add ($ name . '_batch ' , new Route (
90
+ $ batchPattern ,
91
+ $ defaults ,
92
+ [],
93
+ [],
94
+ "" ,
95
+ [],
96
+ [Request::METHOD_POST ]
97
+ ));
89
98
}
90
99
91
100
foreach ($ endpoint ['methods ' ] as $ method ) {
@@ -94,8 +103,8 @@ private function processRestRoute(
94
103
$ defaults ['_controller ' ] = sprintf ('ONGRApiBundle:Rest:%s ' , strtolower ($ method ));
95
104
96
105
if ($ method == Request::METHOD_POST ) {
97
- $ postPattern = $ version. '/ ' . sprintf ('%s ' , strtolower ($ document ));
98
- $ collection ->add ($ name. '_wi ' , new Route ($ postPattern , $ defaults , [], [], "" , [], [$ method ]));
106
+ $ postPattern = $ version . '/ ' . sprintf ('%s ' , strtolower ($ document ));
107
+ $ collection ->add ($ name . '_wi ' , new Route ($ postPattern , $ defaults , [], [], "" , [], [$ method ]));
99
108
}
100
109
101
110
$ collection ->add ($ name , new Route ($ pattern , $ defaults , [], [], "" , [], [$ method ]));
@@ -104,15 +113,15 @@ private function processRestRoute(
104
113
$ defaults ['_controller ' ] = sprintf ('ONGRApiBundle:Variant:%s ' , strtolower ($ method ));
105
114
106
115
if ($ method == Request::METHOD_POST || $ method == Request::METHOD_GET ) {
107
- $ variantPattern = $ pattern . '/_variant ' ;
116
+ $ variantPattern = $ pattern . '/_variant ' ;
108
117
$ collection ->add (
109
- $ name. '_variant_wi ' ,
118
+ $ name . '_variant_wi ' ,
110
119
new Route ($ variantPattern , $ defaults , [], [], "" , [], [$ method ])
111
120
);
112
121
}
113
122
114
- $ variantPattern = $ pattern . '/_variant/{variantId} ' ;
115
- $ collection ->add ($ name. '_variant ' , new Route ($ variantPattern , $ defaults , [], [], "" , [], [$ method ]));
123
+ $ variantPattern = $ pattern . '/_variant/{variantId} ' ;
124
+ $ collection ->add ($ name . '_variant ' , new Route ($ variantPattern , $ defaults , [], [], "" , [], [$ method ]));
116
125
}
117
126
}
118
127
}
0 commit comments