From 0adc1ea0a077a359bfc49f5a4b907d78fed7d88c Mon Sep 17 00:00:00 2001
From: Tymoteusz Motylewski <t.motylewski@gmail.com>
Date: Tue, 4 Jul 2017 22:01:21 +0200
Subject: [PATCH] [TASK] Use constants for 'Image.CropScaleMask' and
 'Image.CropScaleMask'

Constants ProcessedFile::CONTEXT_IMAGECROPSCALEMASK and
ProcessedFile::CONTEXT_IMAGEPREVIEW are now used instead of strings.

Resolves: #81790
Releases: master
Change-Id: I3f8aa0dcbe4cb292f8fe8c6993ecf025c786d70b
Reviewed-on: https://review.typo3.org/53400
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Resource/OnlineMedia/Processing/PreviewProcessing.php   | 6 +++---
 .../Classes/ContentObject/ContentObjectRenderer.php         | 2 +-
 .../frontend/Classes/Controller/ShowImageController.php     | 3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/typo3/sysext/core/Classes/Resource/OnlineMedia/Processing/PreviewProcessing.php b/typo3/sysext/core/Classes/Resource/OnlineMedia/Processing/PreviewProcessing.php
index d89ff7ff2535..2be936ccae4f 100644
--- a/typo3/sysext/core/Classes/Resource/OnlineMedia/Processing/PreviewProcessing.php
+++ b/typo3/sysext/core/Classes/Resource/OnlineMedia/Processing/PreviewProcessing.php
@@ -61,7 +61,7 @@ class PreviewProcessing
      */
     public function processFile(FileProcessingService $fileProcessingService, AbstractDriver $driver, ProcessedFile $processedFile, File $file, $taskType, array $configuration)
     {
-        if ($taskType !== 'Image.Preview' && $taskType !== 'Image.CropScaleMask') {
+        if ($taskType !== ProcessedFile::CONTEXT_IMAGEPREVIEW && $taskType !== ProcessedFile::CONTEXT_IMAGECROPSCALEMASK) {
             return;
         }
         // Check if processing is needed
@@ -80,7 +80,7 @@ class PreviewProcessing
         }
         $temporaryFileNameForResizedThumb = uniqid(PATH_site . 'typo3temp/var/transient/online_media_' . $file->getHashedIdentifier()) . '.jpg';
         switch ($taskType) {
-            case 'Image.Preview':
+            case ProcessedFile::CONTEXT_IMAGEPREVIEW:
                 // Merge custom configuration with default configuration
                 $configuration = array_merge(['width' => 64, 'height' => 64], $configuration);
                 $configuration['width'] = MathUtility::forceIntegerInRange($configuration['width'], 1, 1000);
@@ -88,7 +88,7 @@ class PreviewProcessing
                 $this->resizeImage($temporaryFileName, $temporaryFileNameForResizedThumb, $configuration);
                 break;
 
-            case 'Image.CropScaleMask':
+            case ProcessedFile::CONTEXT_IMAGECROPSCALEMASK:
                 $this->cropScaleImage($temporaryFileName, $temporaryFileNameForResizedThumb, $configuration);
                 break;
         }
diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index 867c48294fb7..9a687ed0fcc7 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -1330,7 +1330,7 @@ class ContentObjectRenderer
                     }
                 }
 
-                $processedFile = $file->process('Image.CropScaleMask', $conf);
+                $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $conf);
                 $JSwindowExpand = isset($conf['JSwindow.']['expand.']) ? $this->stdWrap($conf['JSwindow.']['expand'], $conf['JSwindow.']['expand.']) : $conf['JSwindow.']['expand'];
                 $offset = GeneralUtility::intExplode(',', $JSwindowExpand . ',');
                 $newWindow = isset($conf['JSwindow.']['newWindow.']) ? $this->stdWrap($conf['JSwindow.']['newWindow'], $conf['JSwindow.']['newWindow.']) : $conf['JSwindow.']['newWindow'];
diff --git a/typo3/sysext/frontend/Classes/Controller/ShowImageController.php b/typo3/sysext/frontend/Classes/Controller/ShowImageController.php
index 62748b0d80aa..b53b405f2505 100644
--- a/typo3/sysext/frontend/Classes/Controller/ShowImageController.php
+++ b/typo3/sysext/frontend/Classes/Controller/ShowImageController.php
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Frontend\Controller;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Exception;
+use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -182,7 +183,7 @@ EOF;
             'frame' => $this->frame,
             'crop' => $this->crop,
         ];
-        return $this->file->process('Image.CropScaleMask', $processingConfiguration);
+        return $this->file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $processingConfiguration);
     }
 
     /**
-- 
GitLab