-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Use accepted image formats from client in cache identifier to …
…avoid the caching problem
- Loading branch information
1 parent
b62fcbf
commit 3b4dd42
Showing
6 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Sitegeist\ImageJack\Helper; | ||
|
||
use TYPO3\CMS\Core\Http\ServerRequest; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class RequestHelper | ||
{ | ||
public static function checkForMimeTypeInAcceptHeader(ServerRequest $request, string $mimeType): bool | ||
{ | ||
if ($request->hasHeader('accept')) { | ||
$accept = $request->getHeader('accept'); | ||
$acceptHeader = []; | ||
if (!empty($accept[0])) { | ||
$acceptHeader = GeneralUtility::trimExplode(',', $accept[0]); | ||
} | ||
|
||
return in_array($mimeType, $acceptHeader); | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Sitegeist\ImageJack\Hook; | ||
|
||
use Sitegeist\ImageJack\Helper\RequestHelper; | ||
use Sitegeist\ImageJack\Templates\ConverterInterface; | ||
use TYPO3\CMS\Core\Http\ServerRequest; | ||
|
||
class TsfeHook | ||
{ | ||
public function postProcessHashBase($params): void | ||
{ | ||
/** @var ServerRequest $request */ | ||
$request = $GLOBALS['TYPO3_REQUEST']; | ||
if ($request->hasHeader('accept')) { | ||
$templates = array_filter($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['image_jack']['templates'], function ($template) { | ||
return in_array(ConverterInterface::class, class_implements($template)); | ||
}); | ||
foreach ($templates as $template) { | ||
$targetMimeType = $template::getTargetMimeType(); | ||
if (RequestHelper::checkForMimeTypeInAcceptHeader($request, $targetMimeType)) { | ||
$params['hashParameters']['accepts'][$targetMimeType] = true; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters