This commit is contained in:
2026-03-11 21:48:59 +03:00
parent 980f656a0a
commit 02ad7d83ef
365 changed files with 1 additions and 782 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace Bastion\Handlers;
use Openguru\OpenCartFramework\Http\Request;
use Openguru\OpenCartFramework\ImageTool\ImageFactory;
use Symfony\Component\HttpFoundation\Response;
class ImageHandler
{
private ImageFactory $image;
public function __construct(ImageFactory $image)
{
$this->image = $image;
}
public function getImage(Request $request): Response
{
$path = $request->query->get('path');
[$width, $height] = $this->parseSize($request->query->get('size'));
return $this->image
->make($path)
->resize($width, $height)
->response();
}
private function parseSize(?string $size = null): array
{
if (! $size) {
return [null, null];
}
$sizes = explode('x', $size);
return array_map(static fn($value) => is_numeric($value) ? (int) $value : null, $sizes);
}
}