@@ -140,7 +140,7 @@ public function delete(TranslatorBagInterface $translatorBag): void
140
140
141
141
foreach (array_keys ($ catalogue ->all ()) as $ domain ) {
142
142
foreach ($ this ->getAssetsIds ($ domain ) as $ id ) {
143
- $ responses [$ id ] = $ this ->client ->request ('DELETE ' , sprintf ('assets/%s.json ' , $ id ));
143
+ $ responses [$ id ] = $ this ->client ->request ('DELETE ' , sprintf ('assets/%s.json ' , rawurlencode ( $ id) ));
144
144
}
145
145
}
146
146
@@ -202,7 +202,7 @@ private function translateAssets(array $translations, string $locale): void
202
202
$ responses = [];
203
203
204
204
foreach ($ translations as $ id => $ message ) {
205
- $ responses [$ id ] = $ this ->client ->request ('POST ' , sprintf ('translations/%s/%s ' , $ id, $ locale ), [
205
+ $ responses [$ id ] = $ this ->client ->request ('POST ' , sprintf ('translations/%s/%s ' , rawurlencode ( $ id), rawurlencode ( $ locale) ), [
206
206
'body ' => $ message ,
207
207
]);
208
208
}
@@ -220,13 +220,35 @@ private function tagsAssets(array $ids, string $tag): void
220
220
$ this ->createTag ($ tag );
221
221
}
222
222
223
- $ response = $ this ->client ->request ('POST ' , sprintf ('tags/%s.json ' , $ tag ), [
224
- 'body ' => implode (', ' , $ ids ),
223
+ // Separate ids with and without comma.
224
+ $ idsWithComma = $ idsWithoutComma = [];
225
+ foreach ($ ids as $ id ) {
226
+ if (false !== strpos ($ id , ', ' )) {
227
+ $ idsWithComma [] = $ id ;
228
+ } else {
229
+ $ idsWithoutComma [] = $ id ;
230
+ }
231
+ }
232
+
233
+ // Set tags for all ids without comma.
234
+ $ response = $ this ->client ->request ('POST ' , sprintf ('tags/%s.json ' , rawurlencode ($ tag )), [
235
+ 'body ' => implode (', ' , $ idsWithoutComma ),
225
236
]);
226
237
227
238
if (200 !== $ response ->getStatusCode ()) {
228
239
$ this ->logger ->error (sprintf ('Unable to tag assets with "%s" on Loco: "%s". ' , $ tag , $ response ->getContent (false )));
229
240
}
241
+
242
+ // Set tags for each id with comma one by one.
243
+ foreach ($ idsWithComma as $ id ) {
244
+ $ response = $ this ->client ->request ('POST ' , sprintf ('assets/%s/tags ' , rawurlencode ($ id )), [
245
+ 'body ' => ['name ' => $ tag ],
246
+ ]);
247
+
248
+ if (200 !== $ response ->getStatusCode ()) {
249
+ $ this ->logger ->error (sprintf ('Unable to tag asset "%s" with "%s" on Loco: "%s". ' , $ id , $ tag , $ response ->getContent (false )));
250
+ }
251
+ }
230
252
}
231
253
232
254
private function createTag (string $ tag ): void
0 commit comments