‪TYPO3CMS  11.5
ImageProcessController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
22 use Psr\Log\LoggerAwareInterface;
23 use Psr\Log\LoggerAwareTrait;
28 
32 class ‪ImageProcessController implements LoggerAwareInterface
33 {
34  use LoggerAwareTrait;
35 
40 
42  {
43  $this->imageProcessingService = ‪$imageProcessingService;
44  }
45 
50  public function ‪process(ServerRequestInterface $request): ResponseInterface
51  {
52  $processedFileId = (int)($request->getQueryParams()['id'] ?? 0);
53  try {
54  $processedFile = $this->imageProcessingService->process($processedFileId);
55 
56  return new ‪RedirectResponse(
57  GeneralUtility::locationHeaderUrl($processedFile->getPublicUrl(true) ?? '')
58  );
59  } catch (\Throwable $e) {
60  // Fatal error occurred, which will be responded as 404
61  $this->logger->error('Processing of file with id {processed_file} failed', ['processed_file' => $processedFileId, 'exception' => $e]);
62  }
63 
64  return new HtmlResponse('', 404);
65  }
66 }
‪TYPO3\CMS\Core\Resource\Service\ImageProcessingService
Definition: ImageProcessingService.php:29
‪TYPO3\CMS\Backend\Controller\File\ImageProcessController\__construct
‪__construct(ImageProcessingService $imageProcessingService)
Definition: ImageProcessController.php:40
‪TYPO3\CMS\Backend\Controller\File\ImageProcessController\$imageProcessingService
‪ImageProcessingService $imageProcessingService
Definition: ImageProcessController.php:38
‪TYPO3\CMS\Backend\Controller\File\ImageProcessController
Definition: ImageProcessController.php:33
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:28
‪TYPO3\CMS\Backend\Controller\File\ImageProcessController\process
‪ResponseInterface process(ServerRequestInterface $request)
Definition: ImageProcessController.php:49
‪TYPO3\CMS\Backend\Controller\File
Definition: FileController.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26