Skip to content

Commit

Permalink
[UPGRADE] Remove constants required for supporting TYPO3_11 and TYPO3_12
Browse files Browse the repository at this point in the history
  • Loading branch information
tinzog committed Dec 19, 2024
1 parent 13d688b commit cc8e3cc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 134 deletions.
20 changes: 6 additions & 14 deletions Classes/Backend/Button/ModuleShortcutButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

use function ucfirst;

use const In2code\In2publishCore\TYPO3_V11;

class ModuleShortcutButton extends ShortcutButton
{
public function setRequest(ServerRequestInterface $request): void
Expand All @@ -48,18 +46,12 @@ public function setRequest(ServerRequestInterface $request): void
$route = $request->getAttribute('route');
$arguments = $request->getQueryParams();
$pageId = $request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? null;

if (TYPO3_V11) {
$modConf = $route->getOption('moduleConfiguration');
$displayName = LocalizationUtility::translate($modConf['labels'] . ':mlang_tabs_tab');
} else {
/**
* @noinspection PhpUndefinedClassInspection
* @var ExtbaseModule $module
*/
$module = $route->getOption('module');
$displayName = LocalizationUtility::translate($module->getTitle());
}
/**
* @noinspection PhpUndefinedClassInspection
* @var ExtbaseModule $module
*/
$module = $route->getOption('module');
$displayName = LocalizationUtility::translate($module->getTitle());

if (null !== $pageId) {
if (0 === $pageId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@

use function func_get_args;

use const In2code\In2publishCore\TYPO3_V11;
use const In2code\In2publishCore\TYPO3_V12;

class PublishItemProvider extends AbstractProvider
{
protected $itemsConfiguration = [
Expand Down Expand Up @@ -74,12 +71,9 @@ public function getPriority(): int

public function addItems(array $items): array
{
// In TYPO3 v12 item providers are registered automatically. The explicit config check is required.
if (TYPO3_V12) {
$configContainer = GeneralUtility::makeInstance(ConfigContainer::class);
if (!$configContainer->get('features.contextMenuPublishEntry.enable')) {
return $items;
}
$configContainer = GeneralUtility::makeInstance(ConfigContainer::class);
if (!$configContainer->get('features.contextMenuPublishEntry.enable')) {
return $items;
}
if (!$this->permissionService->isUserAllowedToPublish()) {
return $items;
Expand All @@ -105,11 +99,7 @@ protected function getAdditionalAttributes(string $itemName): array
['id' => $this->identifier],
);
$attributes['data-publish-url'] = $publishUrl;
if (TYPO3_V11) {
$attributes['data-callback-module'] = 'TYPO3/CMS/In2publishCore/ContextMenuPublishEntry';
} else {
$attributes['data-callback-module'] = '@in2code/in2publish_core/context-menu-actions';
}
$attributes['data-callback-module'] = '@in2code/in2publish_core/context-menu-actions';
}
return $attributes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
use function array_key_exists;
use function in_array;

use const In2code\In2publishCore\TYPO3_V11;

class FileEdgeCacheInvalidationService
{
use LocalDatabaseInjection;
Expand Down Expand Up @@ -100,9 +98,7 @@ protected function selectSysFileReferenceRecords(array $uidList): Result
$query->select('tablenames as table', 'uid_foreign as uid')
->from('sys_file_reference')
->where($query->expr()->in('uid_local', $uidList));
if (TYPO3_V11) {
$query->andWhere($query->expr()->eq('table_local', '"sys_file"'));
}

return $query->executeQuery();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
use function strlen;
use function time;

use const In2code\In2publishCore\TYPO3_V11;
use const JSON_THROW_ON_ERROR;

class SystemInformationExportController extends AbstractAdminToolsController
Expand Down Expand Up @@ -132,12 +131,7 @@ public function sysInfoDownloadAction(): void
public function sysInfoUploadAction(): ResponseInterface
{
try {
if (TYPO3_V11) {
/** @var array $file */
$fileName = $this->request->getArgument('jsonFile')['tmp_name'];
} else {
$fileName = !empty($this->request->getUploadedFiles()['jsonFile']) ? $this->request->getUploadedFiles()['jsonFile']->getTemporaryFileName() : null;
}
$fileName = !empty($this->request->getUploadedFiles()['jsonFile']) ? $this->request->getUploadedFiles()['jsonFile']->getTemporaryFileName() : null;
} catch (NoSuchArgumentException $e) {
$this->addFlashMessage(
LocalizationUtility::translate(
Expand Down
5 changes: 0 additions & 5 deletions Classes/Testing/Tests/SshConnection/SshConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
use function array_diff;
use function preg_match;

use const In2code\In2publishCore\TYPO3_V11;

class SshConnectionTest implements TestCaseInterface
{
use ConfigContainerInjection;
Expand Down Expand Up @@ -110,9 +108,6 @@ public function run(): TestResult
'typo3',
'index.php',
];
if (TYPO3_V11) {
$requiredNames[] = 'typo3conf';
}

if (!empty(array_diff($requiredNames, $documentRootFiles))) {
return new TestResult('ssh_connection.foreign_document_root_wrong', TestResult::ERROR);
Expand Down
9 changes: 2 additions & 7 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use TYPO3\CMS\Core\DependencyInjection\PublicServicePass;
use TYPO3\CMS\Core\Utility\GeneralUtility;

use const In2code\In2publishCore\TYPO3_V11;

return static function (ContainerConfigurator $configurator, ContainerBuilder $builder): void {
$configurator->import('Component/*/Services.php');
$configurator->import('Features/*/Services.php');
Expand All @@ -38,11 +36,8 @@
$pageTypeServiceDefinition->setShared(true);
$pageTypeServiceDefinition->setPublic(true);

if (TYPO3_V11) {
$pageTypeServiceDefinition->setClass(LegacyPageTypeService::class);
} else {
$pageTypeServiceDefinition->setClass(PageTypeRegistryService::class);
}
$pageTypeServiceDefinition->setClass(PageTypeRegistryService::class);

$builder->setDefinition(PageTypeService::class, $pageTypeServiceDefinition);

$builder->registerForAutoconfiguration(TestCaseInterface::class)
Expand Down
82 changes: 0 additions & 82 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

use const In2code\In2publishCore\TYPO3_V11;

(static function (): void {
/***************************************************** Guards *****************************************************/
if (!defined('TYPO3')) {
Expand Down Expand Up @@ -70,86 +68,6 @@
return;
}

if (TYPO3_V11) {
/**
* Deprecated registering of Backend Modules
* Register Backend Modules for TYPO3 v11
* can be removed in TYPO3 v13
*/
if ($configContainer->get('module.m1')) {
ExtensionUtility::registerModule(
'in2publish_core',
'web',
'm1',
'',
[
RecordController::class => 'index,detail,publishRecord,toggleFilterStatus',
],
[
'access' => 'user,group',
'iconIdentifier' => 'in2publish-core-overview-module',
'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod1.xlf',
],
);
}
if ($configContainer->get('module.m3')) {
ExtensionUtility::registerModule(
'in2publish_core',
'file',
'm3',
'',
[
FileController::class => 'index,publishFolder,publishFile,toggleFilterStatus',
],
[
'access' => 'user,group',
'iconIdentifier' => 'in2publish-core-file-module',
'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod3.xlf',
],
);
}

if ($configContainer->get('module.m4')) {
$toolsRegistry = GeneralUtility::makeInstance(ToolsRegistry::class);
$controllerActions = $toolsRegistry->processDataForTypo3V11();
if (!empty($controllerActions)) {
ExtensionUtility::registerModule(
'in2publish_core',
'tools',
'm4',
'',
$controllerActions,
[
'access' => 'admin',
'iconIdentifier' => 'in2publish-core-tools-module',
'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod4.xlf',
],
);
}
}

/************************************************ Redirect Support ************************************************/
if (
$configContainer->get('features.redirectsSupport.enable')
&& ExtensionManagementUtility::isLoaded('redirects')
) {
ExtensionUtility::registerModule(
'in2publish_core',
'site',
'm5',
'after:redirects',
[
RedirectController::class => 'list,publish,selectSite',
],
[
'access' => 'user,group',
'iconIdentifier' => 'in2publish-core-redirect-module',
'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod5.xlf',
],
);
}
}

/******************************************* Context Menu Publish Entry *******************************************/
if ($configContainer->get('features.contextMenuPublishEntry.enable')) {
$GLOBALS['TYPO3_CONF_VARS']['BE']['ContextMenu']['ItemProviders'][1595598780] = PublishItemProvider::class;
Expand Down

0 comments on commit cc8e3cc

Please sign in to comment.