Skip to content

Commit

Permalink
[WIP][TASK] Manually migrate ext:theme's extension files
Browse files Browse the repository at this point in the history
- update misc. TYPO3 core API calls
- update EmConfiguration to support upgraded extConf API

Related: #340
  • Loading branch information
Josef Glatz committed Nov 21, 2018
1 parent b0b7444 commit a2264bf
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace JosefGlatz\Theme\Hooks\Backend;

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -25,10 +25,10 @@ public function restrict(array &$params, $parentObject): void
* @var FlashMessage $message Error message to inform the backend user about the barrier
*/
$message = GeneralUtility::makeInstance(FlashMessage::class,
$this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.description', true),
$this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.title', true),
htmlspecialchars($this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.description')),
htmlspecialchars($this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.title')),
FlashMessage::ERROR,
true
);
Expand All @@ -38,7 +38,7 @@ public function restrict(array &$params, $parentObject): void

// @TODO: TYPO3-Distribution: TYPO3v9LTS: Check whether the BackendUtility:getModuleUrl is deprecated and probably switch to implementation like ViewHelpers/Be/UriViewHelper.php
// Simply redirect back to web_ts module on same page ID
$redirectUri = BackendUtility::getModuleUrl(
$redirectUri = (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute(
'web_ts',
[
'id' => $params['id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;

class PageLayoutView implements SingletonInterface
{
Expand All @@ -31,7 +32,7 @@ public function __construct()
public function render(): void
{
$this->pageRenderer->addCssFile(
'../' . ExtensionManagementUtility::siteRelPath('theme') . 'Resources/Public/Css/Backend/PageLayoutView.css'
'../' . PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath('theme')) . 'Resources/Public/Css/Backend/PageLayoutView.css'
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace JosefGlatz\Theme\Hooks\Backend;

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
Expand All @@ -11,6 +11,7 @@
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Lang\LanguageService;

class PageLayoutViewEnrichment implements PageLayoutViewDrawItemHookInterface, SingletonInterface
Expand Down Expand Up @@ -69,7 +70,7 @@ protected function getEditLink(array $row): string
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'],
];
$url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
$url = (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit', $urlParameters);
}
return $url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace JosefGlatz\Theme\Hooks\Backend;

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
Expand All @@ -24,18 +24,17 @@ public function processDatamap_beforeStart(DataHandler $parentObject): void
* @var FlashMessage $message Error message to inform the backend user about the barrier
*/
$message = GeneralUtility::makeInstance(FlashMessage::class,
$this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.description', true),
$this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.title', true),
htmlspecialchars($this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.description')),
htmlspecialchars($this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.title')),
FlashMessage::ERROR,
true
);
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$messageQueue = $flashMessageService->getMessageQueueByIdentifier();
$messageQueue->addMessage($message);
// @TODO: TYPO3-Distribution: TYPO3v9LTS: Check whether the BackendUtility:getModuleUrl is deprecated and probably switch to implementation like ViewHelpers/Be/UriViewHelper.php
$redirectUri = BackendUtility::getModuleUrl(
$redirectUri = (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute(
'web_ts',
[
'id' => (int)$parentObject->datamap['sys_template']['NEW']['pid'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ class ClearProcessedFilesMenuItem implements ClearCacheActionsHookInterface
*
* @param array $cacheActions Array of CacheMenuItems
* @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier)
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
public function manipulateCacheActions(&$cacheActions, &$optionValues)
{
$backendUser = $this->getBackendUser();
$languagePrefix = 'LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:clearcacheaction.clear.processedfiles.';
$menuItemPath = $this->getUriBuilder()->buildUriFromRoute('ajax_' . 'theme_clear_processedfiles');
$menuItemPath = (string)$this->getUriBuilder()->buildUriFromRoute('ajax_' . 'theme_clear_processedfiles');

if ($backendUser->isAdmin() && ($backendUser->getTSConfigVal('options.clearCache.processedfiles') || $this->applicationContextIsDevelopment())) {
if ($backendUser->isAdmin() && ((bool)($backendUser->getTSConfig()['options.']['clearCache.']['processedfiles'] ?? false) || $this->applicationContextIsDevelopment())) {
$cacheActions[] = [
'id' => 'theme_clear_processedfiles',
'title' => $languagePrefix . 'title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public function adjustEditDocumentController(EditDocumentController $editDocumen
* @var FlashMessage $message Error message to inform the backend user about the barrier
*/
$message = GeneralUtility::makeInstance(FlashMessage::class,
$this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.description', true),
$this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.title', true),
htmlspecialchars($this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.description')),
htmlspecialchars($this->getLanguageService()
->sL('LLL:EXT:theme/Resources/Private/Language/locallang_BackendGeneral.xlf:hooks.dataHandler.prevent.sys_template.title')),
FlashMessage::ERROR,
true
);
Expand Down
18 changes: 9 additions & 9 deletions app/web/typo3conf/ext/theme/Classes/Utility/EmConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace JosefGlatz\Theme\Utility;

use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Utility class to get the settings from Extension Manager
Expand All @@ -17,10 +19,10 @@ class EmConfiguration
* @return \JosefGlatz\Theme\Domain\Model\Dto\EmConfiguration
* @throws \Exception If the configuration is invalid.
*/
public static function getSettings()
public static function getSettings(): \JosefGlatz\Theme\Domain\Model\Dto\EmConfiguration
{
$configuration = self::parseSettings();
require_once(ExtensionManagementUtility::extPath('theme') . 'Classes/Domain/Model/Dto/EmConfiguration.php');
require_once ExtensionManagementUtility::extPath('theme') . 'Classes/Domain/Model/Dto/EmConfiguration.php';
$settings = new \JosefGlatz\Theme\Domain\Model\Dto\EmConfiguration($configuration);

return $settings;
Expand All @@ -30,18 +32,16 @@ public static function getSettings()
* Parse settings and return it as array
*
* @return array unserialized extConf settings
* @throws \TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException
* @throws \TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException
*/
public static function parseSettings(): array
protected static function parseSettings(): array
{
$settings = unserialize(
(string)$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['theme'],
[]
);
$settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('theme');

if (!is_array($settings)) {
if (!\is_array($settings)) {
$settings = [];
}

return $settings;
}
}

0 comments on commit a2264bf

Please sign in to comment.