Commit e4956606 authored by Tim Wagner's avatar Tim Wagner
Browse files

[BUGFIX] StreamFactory does not exist in TYPO3 9

parent 6f1b585a
......@@ -36,6 +36,7 @@ use SGalinski\ContentReplacer\Service\CustomParserService;
use SGalinski\ContentReplacer\Service\SpanParserService;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\TypoScriptAspect;
use TYPO3\CMS\Core\Http\Stream;
use TYPO3\CMS\Core\Http\StreamFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager;
......@@ -90,8 +91,17 @@ class ContentReplacerMiddleware implements MiddlewareInterface {
$content = $this->parseAndReplace($customParser, $content);
}
$streamFactory = GeneralUtility::makeInstance(StreamFactory::class);
return $response->withBody($streamFactory->createStream($content));
// StreamFactory is not available in TYPO3 9 yet.
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '10.0.0', '<')) {
$stream = new Stream('php://temp', 'r+');
if ($content !== '') {
$stream->write($content);
}
} else {
$streamFactory = GeneralUtility::makeInstance(StreamFactory::class);
$stream = $streamFactory->createStream($content);
}
return $response->withBody($stream);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment