@@ -51,7 +51,7 @@ public function postAction(RestRequest $restRequest, $id = null)
51
51
$ types = $ repository ->getTypes ();
52
52
$ data ['_id ' ] = $ id ;
53
53
$ repository ->getManager ()->getConnection ()->bulk ('create ' , reset ($ types ), $ data );
54
- $ repository ->getManager ()->commit ();
54
+ $ repository ->getManager ()->getConnection ()-> commit (! $ this -> isBatch () );
55
55
56
56
return $ this ->renderRest (
57
57
null ,
@@ -110,7 +110,7 @@ public function putAction(RestRequest $restRequest, $id = null)
110
110
$ types = $ repository ->getTypes ();
111
111
$ data ['_id ' ] = $ id ;
112
112
$ repository ->getManager ()->getConnection ()->bulk ('index ' , reset ($ types ), $ data );
113
- $ repository ->getManager ()->commit ();
113
+ $ repository ->getManager ()->getConnection ()-> commit (! $ this -> isBatch () );
114
114
115
115
return $ this ->renderRest (
116
116
null ,
@@ -129,14 +129,22 @@ public function deleteAction(RestRequest $restRequest, $id = null)
129
129
}
130
130
131
131
$ connection = $ restRequest ->getRepository ()->getManager ()->getConnection ();
132
+ $ types = $ restRequest ->getRepository ()->getTypes ();
133
+
132
134
try {
133
- $ connection ->delete (
134
- [
135
- 'id ' => $ id ,
136
- 'type ' => $ restRequest ->getRepository ()->getTypes (),
137
- 'index ' => $ connection ->getIndexName (),
138
- ]
139
- );
135
+ if ($ this ->isBatch ()) {
136
+ $ types = $ restRequest ->getRepository ()->getTypes ();
137
+ $ connection ->bulk ('delete ' , reset ($ types ), ['_id ' => $ id ]);
138
+ $ connection ->commit (false );
139
+ } else {
140
+ $ connection ->delete (
141
+ [
142
+ 'id ' => $ id ,
143
+ 'type ' => $ types ,
144
+ 'index ' => $ connection ->getIndexName (),
145
+ ]
146
+ );
147
+ }
140
148
} catch (Missing404Exception $ e ) {
141
149
return $ this ->renderRest (
142
150
['message ' => $ this ->trans ('response.error.not_found ' , ['%id% ' => $ id ])],
0 commit comments