@@ -34,9 +34,10 @@ public function __construct(
3434 LoggerInterface $ logger
3535 ) {
3636 $ this ->prerenderConfigHelper = $ prerenderConfigHelper ;
37- $ this ->client = $ client ;
3837 $ this ->jsonSerializer = $ jsonSerializer ;
3938 $ this ->logger = $ logger ;
39+ $ this ->client = $ client ;
40+ $ this ->client ->addHeader ('content-type ' , 'application/json ' );
4041 }
4142
4243 public function recacheUrls (array $ urls , int $ storeId ): void
@@ -50,13 +51,9 @@ public function recacheUrls(array $urls, int $storeId): void
5051 return ;
5152 }
5253
53- if (count ($ urls ) > self ::MAX_URLS ) {
54- $ batches = array_chunk ($ urls , self ::MAX_URLS );
55- foreach ($ batches as $ batch ) {
56- $ this ->sendRequest ($ batch , $ token );
57- }
58- } else {
59- $ this ->sendRequest ($ urls , $ token );
54+ $ batches = array_chunk ($ urls , self ::MAX_URLS );
55+ foreach ($ batches as $ batch ) {
56+ $ this ->sendRequest ($ batch , $ token );
6057 }
6158 }
6259
@@ -68,7 +65,6 @@ private function sendRequest(array $urls, string $token): void
6865 'urls ' => $ urls
6966 ]
7067 );
71- $ this ->client ->addHeader ('content-type ' , 'application/json ' );
7268 try {
7369 $ this ->client ->post (self ::PRERENDER_RECACHE_URL , $ payload );
7470 } catch (\Exception $ e ) {
0 commit comments