Skip to content

Commit 855dc1e

Browse files
authored
[TASK] TYPO3 8.6 migration (#45)
* [TASK] TYPO3 8.6 migration * Apply fixes from StyleCI (#46) Closes !41 Fixes #36
1 parent 855f44f commit 855dc1e

File tree

9 files changed

+94
-55
lines changed

9 files changed

+94
-55
lines changed

Classes/ExtMgm/Statefield.php

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44

55
use KayStrobach\Dyncss\Parser\AbstractParser;
66
use TYPO3\CMS\Core\Messaging\FlashMessage;
7+
use TYPO3\CMS\Core\Messaging\FlashMessageService;
8+
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
79
use TYPO3\CMS\Core\Utility\GeneralUtility;
10+
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
811

912
/**
10-
* @todo missing docblock
13+
* Render state field for extension manager configuration
1114
*/
1215
class Statefield
1316
{
1417
/**
15-
* @todo missing docblock
18+
* @var FlashMessageService
19+
*/
20+
protected $flashMessageService = null;
21+
22+
/**
23+
* Render state field
1624
*/
1725
public function main()
1826
{
@@ -29,21 +37,57 @@ public function main()
2937
$buffer .= '<td>'.$parser->getVersion().'</td>';
3038
$buffer .= '</tr>';
3139
}
32-
$flashMessage = new FlashMessage(
40+
/** @var FlashMessage $flashMessage */
41+
$flashMessage = GeneralUtility::makeInstance(
42+
FlashMessage::class,
3343
'Congrats, you have '.count($handlers).' handlers registered.',
3444
'',
35-
FlashMessage::OK
45+
FlashMessage::OK,
46+
true
3647
);
37-
38-
return $flashMessage->render().'<table class="t3-table"><thead><tr><th>extension</th><th>class</th><th>name</th><th>version</th></tr></thead>'.$buffer.'</table>';
48+
$this->addFlashMessage($flashMessage);
49+
$buffer = '<table class="t3-table table"><thead><tr><th>extension</th><th>class</th><th>name</th><th>version</th></tr></thead>'.$buffer.'</table>';
3950
} else {
40-
$flashMessage = new FlashMessage(
51+
/** @var FlashMessage $flashMessage */
52+
$flashMessage = GeneralUtility::makeInstance(
53+
FlashMessage::class,
4154
'Please install one of the dyncss_* extensions',
4255
'No handler registered! - No dynamic css is handled at all ;/',
43-
FlashMessage::ERROR
56+
FlashMessage::WARNING,
57+
true
4458
);
59+
$this->addFlashMessage($flashMessage);
60+
return $this->renderFlashMessage();
61+
}
62+
$renderedFlashMessages = $this->renderFlashMessage();
63+
return $renderedFlashMessages . $buffer;
64+
}
4565

46-
return $flashMessage->render();
66+
/**
67+
* Add flash message to message queue
68+
*
69+
* @param FlashMessage $flashMessage
70+
* @return void
71+
*/
72+
protected function addFlashMessage(FlashMessage $flashMessage)
73+
{
74+
if (!($this->flashMessageService instanceof FlashMessageService)) {
75+
$this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
4776
}
77+
/** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
78+
$defaultFlashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier();
79+
$defaultFlashMessageQueue->enqueue($flashMessage);
80+
}
81+
82+
/**
83+
* Render queued flash messages
84+
*
85+
* @return string
86+
*/
87+
protected function renderFlashMessage()
88+
{
89+
/** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
90+
$defaultFlashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier();
91+
return $defaultFlashMessageQueue->renderFlashMessages();
4892
}
4993
}

Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* Date: 22.04.15
66
* Time: 15:52
77
*/
8-
98
namespace KayStrobach\Dyncss\Hooks\Backend\Toolbar;
109

1110
use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface;
1211
use TYPO3\CMS\Backend\Utility\BackendUtility;
13-
use TYPO3\CMS\Backend\Utility\IconUtility;
1412
use TYPO3\CMS\Core\Utility\GeneralUtility;
13+
use TYPO3\CMS\Core\Imaging\Icon;
14+
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
1515

1616
class ClearCacheActionsHook implements ClearCacheActionsHookInterface
1717
{
@@ -28,42 +28,23 @@ public function manipulateCacheActions(&$cacheActions, &$optionValues)
2828
{
2929
if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system')
3030
|| GeneralUtility::getApplicationContext()->isDevelopment()
31-
|| ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->getBackendUser()->isAdmin())) {
32-
33-
/**
34-
* Validate Typo3 version and use old core-API for versions below 7.1
35-
*
36-
* @link https://docs.typo3.org/typo3cms/extensions/core/latest/Changelog/7.1/Deprecation-64922-DeprecatedEntryPoints.html
37-
*/
38-
$hrefParams = ['vC' => $this->getBackendUser()->veriCode(), 'cacheCmd' => 'dyncss', 'ajaxCall' => 1];
39-
if (version_compare(TYPO3_version, '7.1', '<')) {
40-
$href = 'tce_db.php?' . http_build_query($hrefParams);
41-
} else {
42-
$href = BackendUtility::getModuleUrl('tce_db', $hrefParams);
43-
}
44-
45-
31+
|| ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->getBackendUser()->isAdmin())
32+
) {
33+
$hrefParams = ['cacheCmd' => 'dyncss', 'ajaxCall' => 1];
34+
/** @var \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory */
35+
$iconFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class);
36+
$translationPrefix = 'LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.';
4637
$cacheActions[] = [
4738
'id' => 'dyncss',
48-
'title' => $this->getLanguageService()->sL('LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.title', true),
49-
'description' => $this->getLanguageService()->sL('LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.description', true),
50-
'href' => $href . BackendUtility::getUrlToken('tceAction'),
51-
'icon' => IconUtility::getSpriteIcon('extensions-dyncss-lightning-blue')
39+
'title' => LocalizationUtility::translate($translationPrefix . 'title', 'Dyncss'),
40+
'description' => LocalizationUtility::translate($translationPrefix . 'description', 'Dyncss'),
41+
'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams),
42+
'icon' => $iconFactory->getIcon('actions-system-cache-clear-dyncss', Icon::SIZE_SMALL)->render()
5243
];
5344
$optionValues[] = 'dyncss';
5445
}
5546
}
5647

57-
/**
58-
* Returns LanguageService
59-
*
60-
* @return \TYPO3\CMS\Lang\LanguageService
61-
*/
62-
protected function getLanguageService()
63-
{
64-
return $GLOBALS['LANG'];
65-
}
66-
6748
/**
6849
* Returns the current BE user.
6950
*

Classes/Parser/AbstractParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function setOverrides($overwrites)
232232
unset($overwrites[$key]);
233233
}
234234
}
235-
$this->overrides = ArrayUtility::arrayMergeRecursiveOverrule($this->overrides, $overwrites);
235+
$this->overrides = array_replace_recursive($this->overrides, $overwrites);
236236
}
237237

238238
/**
Lines changed: 1 addition & 0 deletions
Loading
-1.69 KB
Binary file not shown.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "kaystrobach/dyncss",
33
"description": "Compile your CSS dynamically with DynCss Adapters.",
44
"type": "typo3-cms-extension",
5-
"version": "0.7.9",
5+
"version": "0.8.0",
66
"license": "GPL-2.0+",
77
"require": {
8-
"typo3/cms-core": ">=6.2.0,<8.0"
8+
"typo3/cms-core": ">=7.6.15,<8.7"
99
},
1010
"require-dev": {
11-
"typo3/cms": "^7.6"
11+
"typo3/cms": "^8.6"
1212
},
1313
"replace": {
1414
"dyncss": "self.version",

ext_emconf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'description' => 'Compile your CSS dynamically with DynCss Adapters.',
1616
'category' => 'fe',
1717
'shy' => 0,
18-
'version' => '0.7.9',
18+
'version' => '0.8.0',
1919
'dependencies' => '',
2020
'conflicts' => '',
2121
'priority' => '',
@@ -34,7 +34,7 @@
3434
'CGLcompliance_note' => '',
3535
'constraints' => [
3636
'depends' => [
37-
'typo3' => '6.2.10-7.6.99',
37+
'typo3' => '7.6.15-8.6.99',
3838
],
3939
'conflicts' => [
4040
],

ext_localconf.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838

3939
// clear cache item
40-
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][] = 'KayStrobach\Dyncss\Hooks\T3libTcemainHook->clearCachePostProc';
41-
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'][] = 'KayStrobach\Dyncss\Hooks\Backend\Toolbar\ClearCacheActionsHook';
42-
43-
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'KayStrobach\Dyncss\Command\DyncssCommandController';
40+
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][] = 'KayStrobach\Dyncss\Hooks\T3libTcemainHook->clearCachePostProc';
41+
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'][] = 'KayStrobach\Dyncss\Hooks\Backend\Toolbar\ClearCacheActionsHook';
42+
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'KayStrobach\Dyncss\Command\DyncssCommandController';

ext_tables.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
<?php
2-
3-
\TYPO3\CMS\Backend\Sprite\SpriteManager::addSingleIcons(
4-
[
5-
'lightning-blue' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY).'Resources/Public/Icons/lightning_blue.png',
6-
],
2+
defined('TYPO3_MODE') || die('Access denied.');
3+
call_user_func(
4+
function ($extKey) {
5+
// Add/register icons
6+
if (TYPO3_MODE === 'BE') {
7+
// register svg icons: identifier and filename
8+
$iconsSvg = [
9+
'actions-system-cache-clear-dyncss' => 'actions-system-cache-clear-dyncss.svg'
10+
];
11+
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
12+
foreach ($iconsSvg as $identifier => $path) {
13+
$iconRegistry->registerIcon(
14+
$identifier,
15+
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
16+
['source' => 'EXT:' . $extKey . '/Resources/Public/Icons/' . $path]
17+
);
18+
}
19+
}
20+
},
721
$_EXTKEY
822
);

0 commit comments

Comments
 (0)