From 0780e2596c3fe6c065612752ccd5b6803a569689 Mon Sep 17 00:00:00 2001 From: David Mellen Date: Wed, 14 Feb 2024 14:20:44 +0100 Subject: [PATCH] feat: add processImage function to jsonService --- Classes/Service/JsonService.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Classes/Service/JsonService.php b/Classes/Service/JsonService.php index 94c5e7f..515f038 100644 --- a/Classes/Service/JsonService.php +++ b/Classes/Service/JsonService.php @@ -4,12 +4,14 @@ namespace Remind\Headless\Service; +use FriendsOfTYPO3\Headless\Utility\FileUtility; use Psr\Http\Message\ServerRequestInterface; use Psr\Log\LoggerInterface; use TYPO3\CMS\Core\Pagination\PaginationInterface; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; +use TYPO3\CMS\Extbase\Service\ImageService; class JsonService { @@ -18,6 +20,8 @@ class JsonService public function __construct( private readonly UriBuilder $uriBuilder, private readonly LoggerInterface $logger, + private readonly ImageService $imageService, + private readonly FileUtility $fileUtility, RequestBuilder $requestBuilder, ConfigurationManagerInterface $configurationManager ) { @@ -87,6 +91,12 @@ public function serializePagination(PaginationInterface $pagination, string $que return $result; } + public function processImage(int $uid): ?array + { + $imageObj = $this->imageService->getImage(strval($uid), null, true); + return $this->fileUtility->processFile($imageObj); + } + private function getRequest(): ServerRequestInterface { return $GLOBALS['TYPO3_REQUEST'];