From 484be18957a0ac7d52e029b50e19854cd27add1f Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Sat, 18 Jul 2026 20:18:37 +0400 Subject: [PATCH] Refactor remote image download to fluent HttpClient helper --- helpers/functions.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/helpers/functions.php b/helpers/functions.php index 34bea2e..602b4a6 100644 --- a/helpers/functions.php +++ b/helpers/functions.php @@ -11,7 +11,6 @@ use Quantum\Config\Exceptions\ConfigException; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; -use Quantum\HttpClient\HttpClient; /** * Gets the url with the selected language @@ -74,13 +73,15 @@ function save_remote_image(string $imageUrl, string $userDirectory, string $imag $imageName = slugify($imageName) . '.jpg'; - $httpClient = new HttpClient(); - $httpClient->createRequest($imageUrl); - $httpClient->setMethod('GET'); - $httpClient->setOpt(CURLOPT_FOLLOWLOCATION, true); - $httpClient->start(); + $httpClient = httpRequest($imageUrl) + ->setMethod('GET') + ->setOpt(CURLOPT_FOLLOWLOCATION, true) + ->start(); - $fs->put(uploads_dir() . DS . $userDirectory . DS . $imageName, $httpClient->getResponseBody()); + $fs->put( + uploads_dir() . DS . $userDirectory . DS . $imageName, + $httpClient->getResponseBody() + ); return $imageName; }