Skip to content

Commit a89ed04

Browse files
committed
More TYPO3 v14 migrations
1 parent 670294c commit a89ed04

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

Classes/Cache/StaticDatabaseBackend.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use SFC\Staticfilecache\Service\ConfigurationService;
1010
use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
1111
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
12+
use TYPO3\CMS\Core\Information\Typo3Version;
13+
use TYPO3\CMS\Core\Resource\ResourceFactory;
1214
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
1315
use TYPO3\CMS\Core\Utility\GeneralUtility;
1416

@@ -24,12 +26,18 @@ abstract class StaticDatabaseBackend extends Typo3DatabaseBackend implements Log
2426
/**
2527
* Constructs this backend.
2628
*
27-
* @param string $context application context
29+
* @param mixed $context application context
2830
* @param array $options Configuration options - depends on the actual backend
2931
*/
3032
public function __construct($context, array $options = [])
3133
{
32-
parent::__construct($context, $options);
34+
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 14) {
35+
// @phpstan-ignore-next-line
36+
parent::__construct($context, $options);
37+
} else {
38+
// Note. In v14 there is only the options array. So the first Param are the options.
39+
parent::__construct($context);
40+
}
3341
$this->configuration = GeneralUtility::makeInstance(ConfigurationService::class);
3442
}
3543

Classes/Generator/AbstractGenerator.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55
namespace SFC\Staticfilecache\Generator;
66

77
use Psr\EventDispatcher\EventDispatcherInterface;
8+
use Psr\Http\Message\ServerRequestInterface;
89
use SFC\Staticfilecache\Event\GeneratorCreate;
910
use SFC\Staticfilecache\Event\GeneratorRemove;
1011
use SFC\Staticfilecache\Service\ConfigurationService;
1112
use SFC\Staticfilecache\Service\RemoveService;
1213
use TYPO3\CMS\Core\Utility\GeneralUtility;
13-
use TYPO3\CMS\Fluid\View\StandaloneView;
14+
use TYPO3\CMS\Core\View\ViewFactoryInterface;
15+
use TYPO3\CMS\Core\View\ViewFactoryData;
1416

1517
abstract class AbstractGenerator
1618
{
17-
public function __construct(protected EventDispatcherInterface $eventDispatcher) {}
19+
public function __construct(
20+
protected EventDispatcherInterface $eventDispatcher,
21+
protected ViewFactoryInterface $viewFactory,
22+
) {}
1823

1924
abstract public function generate(GeneratorCreate $generatorCreateEvent): void;
2025

@@ -38,11 +43,12 @@ protected function removeFile(string $fileName): void
3843

3944
protected function renderTemplateToFile(string $templateName, array $variables, string $htaccessFile): void
4045
{
41-
/** @var StandaloneView $renderer */
42-
$renderer = GeneralUtility::makeInstance(StandaloneView::class);
43-
$renderer->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateName));
44-
$renderer->assignMultiple($variables);
45-
$content = trim($renderer->render());
46+
$view = $this->viewFactory->create(new ViewFactoryData(
47+
templatePathAndFilename: GeneralUtility::getFileAbsFileName($templateName),
48+
));
49+
$view->assignMultiple($variables);
50+
$content = trim($view->render());
51+
4652
// Note: Create even empty htaccess files (do not check!!!), so the delete is in sync
4753
$this->writeFile($htaccessFile, $content);
4854
}

Classes/Traits/CacheTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*
2727
* $result = $this->cacheRemoteUri('https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png');
2828
*/
29+
// @phpstan-ignore-next-line
2930
trait CacheTrait
3031
{
3132
/**

0 commit comments

Comments
 (0)