Migrate the method BackendUtility::editOnClick() to use UriBuilder API
$pid = 2;
$params = '&edit[pages][' . $pid . ']=new&returnNewPageId=1';
-$url = BackendUtility::editOnClick($params);
+$url = GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit') . $params . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));;
Migrate the method BackendUtility::editOnClick() to use UriBuilder API
$table = 'fe_users';
$where = 'uid > 5';
$fields = ['uid', 'pid'];
-$record = BackendUtility::getRecordRaw($table, $where, $fields);
+
+$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+$queryBuilder->getRestrictions()->removeAll();
+
+$record = $queryBuilder->select(GeneralUtility::trimExplode(',', $fields, true))
+ ->from($table)
+ ->where(QueryHelper::stripLogicalOperatorPrefix($where))
+ ->execute()
+ ->fetch();
- class:
Ssch\TYPO3Rector\Rector\Frontend\ContentObject\CallEnableFieldsFromPageRepositoryRector
- test fixtures
Call enable fields from PageRepository instead of ContentObjectRenderer
$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
-$contentObjectRenderer->enableFields('pages', false, []);
+GeneralUtility::makeInstance(PageRepository::class)->enableFields('pages', -1, []);
Turns old default value to parameter in ConsoleOutput->askAndValidate() and/or ConsoleOutput->select() method
-$this->output->select('The question', [1, 2, 3], null, false, false);
+$this->output->select('The question', [1, 2, 3], null, false, null);
Turns method call names to new ones.
$someObject = new StandaloneView();
-$someObject->setLayoutRootPath();
-$someObject->getLayoutRootPath();
-$someObject->setPartialRootPath();
-$someObject->getPartialRootPath();
+$someObject->setLayoutRootPaths();
+$someObject->getLayoutRootPaths();
+$someObject->setPartialRootPaths();
+$someObject->getPartialRootPaths();
Change the extensions to check for info instead of info_pagetsconfig.
-if(ExtensionManagementUtility::isLoaded('info_pagetsconfig')) {
+if(ExtensionManagementUtility::isLoaded('info')) {
+
}
$packageManager = GeneralUtility::makeInstance(PackageManager::class);
-if($packageManager->isActive('info_pagetsconfig')) {
+if($packageManager->isActive('info')) {
}
Change the extensions to check for workspaces instead of version.
-if (ExtensionManagementUtility::isLoaded('version')) {
+if (ExtensionManagementUtility::isLoaded('workspaces')) {
}
$packageManager = GeneralUtility::makeInstance(PackageManager::class);
-if ($packageManager->isActive('version')) {
+if ($packageManager->isActive('workspaces')) {
}
- class:
Ssch\TYPO3Rector\Rector\Extbase\ConfigurationManagerAddControllerConfigurationMethodRector
- test fixtures
Add additional method getControllerConfiguration for AbstractConfigurationManager
final class MyExtbaseConfigurationManager extends AbstractConfigurationManager
{
protected function getSwitchableControllerActions($extensionName, $pluginName)
{
$switchableControllerActions = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] ?? false;
if ( ! is_array($switchableControllerActions)) {
$switchableControllerActions = [];
}
return $switchableControllerActions;
}
+
+ protected function getControllerConfiguration($extensionName, $pluginName): array
+ {
+ return $this->getSwitchableControllerActions($extensionName, $pluginName);
+ }
}
Turns defined constant to static method call of new Environment API.
-PATH_thisScript;
+Environment::getCurrentScript();
Migrate the method DataHandler::rmComma() to use rtrim()
$inList = '1,2,3,';
$dataHandler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
-$inList = $dataHandler->rmComma(trim($inList));
+$inList = rtrim(trim($inList), ',');
Change parameter $excludeServiceKeys explicity to an array
-GeneralUtility::makeInstanceService('serviceType', 'serviceSubType', 'key1, key2');
-ExtensionManagementUtility::findService('serviceType', 'serviceSubType', 'key1, key2');
+GeneralUtility::makeInstanceService('serviceType', 'serviceSubType', ['key1', 'key2']);
+ExtensionManagementUtility::findService('serviceType', 'serviceSubType', ['key1', 'key2']);
Use findByPidsAndAuthorId instead of findByPidsAndAuthor
$sysNoteRepository = GeneralUtility::makeInstance(SysNoteRepository::class);
$backendUser = new BackendUser();
-$sysNoteRepository->findByPidsAndAuthor('1,2,3', $backendUser);
+$sysNoteRepository->findByPidsAndAuthorId('1,2,3', $backendUser->getUid());
Turns properties with @ignorevalidation
to properties with @TYPO3\CMS\Extbase\Annotation\IgnoreValidation
/**
- * @ignorevalidation $param
+ * @TYPO3\CMS\Extbase\Annotation\IgnoreValidation("param")
*/
public function method($param)
{
}
Turns properties with @inject
to setter injection
/**
* @var SomeService
- * @inject
*/
-private $someService;
+private $someService;
+
+public function injectSomeService(SomeService $someService)
+{
+ $this->someService = $someService;
+}
- class:
Ssch\TYPO3Rector\Rector\Extbase\InjectEnvironmentServiceIfNeededInResponseRector
- test fixtures
Inject EnvironmentService if needed in subclass of Response
class MyResponse extends Response
{
+ /**
+ * @var \TYPO3\CMS\Extbase\Service\EnvironmentService
+ */
+ protected $environmentService;
+
public function myMethod()
{
if ($this->environmentService->isEnvironmentInCliMode()) {
}
+ }
+
+ public function injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
+ {
+ $this->environmentService = $environmentService;
}
}
class MyOtherResponse extends Response
{
public function myMethod()
{
}
}
- class:
Ssch\TYPO3Rector\Rector\Core\Utility\MoveApplicationContextToEnvironmentApiRector
- test fixtures
Use Environment API to fetch application context
-GeneralUtility::getApplicationContext();
+Environment::getContext();
- class:
Ssch\TYPO3Rector\Rector\Fluid\ViewHelpers\MoveRenderArgumentsToInitializeArgumentsMethodRector
- test fixtures
Move render method arguments to initializeArguments method
class MyViewHelper implements ViewHelperInterface
{
- public function render(array $firstParameter, string $secondParameter = null)
+ public function initializeArguments()
{
+ $this->registerArgument('firstParameter', 'array', '', true);
+ $this->registerArgument('secondParameter', 'string', '', false, null);
+ }
+
+ public function render()
+ {
+ $firstParameter = $this->arguments['firstParameter'];
+ $secondParameter = $this->arguments['secondParameter'];
}
}
Changes TYPO3_db constants to $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'].
-$database = TYPO3_db;
-$username = TYPO3_db_username;
-$password = TYPO3_db_password;
-$host = TYPO3_db_host;
+$database = $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'];
+$username = $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['user'];
+$password = $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['password'];
+$host = $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['host'];
- class:
Ssch\TYPO3Rector\Rector\Core\Page\RefactorDeprecatedConcatenateMethodsPageRendererRector
- test fixtures
Turns method call names to new ones.
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
-$files = $someObject->getConcatenateFiles();
+$files = array_merge($this->getConcatenateCss(), $this->getConcatenateJavascript());
Refactor GeneralUtility deprecationLog methods
-GeneralUtility::logDeprecatedFunction();
-GeneralUtility::logDeprecatedViewHelperAttribute();
-GeneralUtility::deprecationLog('Message');
-GeneralUtility::getDeprecationLogFileName();
+trigger_error('A useful message', E_USER_DEPRECATED);
- class:
Ssch\TYPO3Rector\Rector\Core\Utility\RefactorExplodeUrl2ArrayFromGeneralUtilityRector
- test fixtures
Remove second argument of GeneralUtility::explodeUrl2Array if it is false or just use function parse_str if it is true
-$variable = GeneralUtility::explodeUrl2Array('https://www.domain.com', true);
-$variable2 = GeneralUtility::explodeUrl2Array('https://www.domain.com', false);
+parse_str('https://www.domain.com', $variable);
+$variable2 = GeneralUtility::explodeUrl2Array('https://www.domain.com');
- class:
Ssch\TYPO3Rector\Rector\Core\Utility\RefactorIdnaEncodeMethodToNativeFunctionRector
- test fixtures
Use native function idn_to_ascii instead of GeneralUtility::idnaEncode
-$domain = GeneralUtility::idnaEncode('domain.com');
-$email = GeneralUtility::idnaEncode('[email protected]');
+$domain = idn_to_ascii('domain.com', IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
+$email = 'email@' . idn_to_ascii('domain.com', IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
- class:
Ssch\TYPO3Rector\Rector\Core\Utility\RefactorMethodsFromExtensionManagementUtilityRector
- test fixtures
Refactor deprecated methods from ExtensionManagementUtility.
-ExtensionManagementUtility::removeCacheFiles();
+GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->flushCachesInGroup('system');
- class:
Ssch\TYPO3Rector\Rector\Frontend\ContentObject\RefactorRemovedMarkerMethodsFromContentObjectRendererRector
- test fixtures
Refactor removed Marker-related methods from ContentObjectRenderer.
// build template
-$template = $this->cObj->getSubpart($this->config['templateFile'], '###TEMPLATE###');
-$html = $this->cObj->substituteSubpart($html, '###ADDITONAL_KEYWORD###', '');
-$html2 = $this->cObj->substituteSubpartArray($html2, []);
-$content .= $this->cObj->substituteMarker($content, $marker, $markContent);
-$content .= $this->cObj->substituteMarkerArrayCached($template, $markerArray, $subpartArray, []);
-$content .= $this->cObj->substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
-$content .= $this->cObj->substituteMarkerInObject($tree, $markContentArray);
-$content .= $this->cObj->substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
-$content .= $this->cObj->fillInMarkerArray($markContentArray, $row, $fieldList, $nl2br, $prefix, $HSC);
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+$template = GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->getSubpart($this->config['templateFile'], '###TEMPLATE###');
+$html = GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->substituteSubpart($html, '###ADDITONAL_KEYWORD###', '');
+$html2 = GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->substituteSubpartArray($html2, []);
+$content .= GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->substituteMarker($content, $marker, $markContent);
+$content .= GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->substituteMarkerArrayCached($template, $markerArray, $subpartArray, []);
+$content .= GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
+$content .= GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->substituteMarkerInObject($tree, $markContentArray);
+$content .= GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
+$content .= GeneralUtility::makeInstance(MarkerBasedTemplateService::class)->fillInMarkerArray($markContentArray, $row, $fieldList, $nl2br, $prefix, $HSC, !empty($GLOBALS['TSFE']->xhtmlDoctype));
- class:
Ssch\TYPO3Rector\Rector\Frontend\ContentObject\RefactorRemovedMethodsFromContentObjectRendererRector
- test fixtures
Refactor removed methods from ContentObjectRenderer.
-$cObj->RECORDS(['tables' => 'tt_content', 'source' => '1,2,3']);
+$cObj->cObjGetSingle('RECORDS', ['tables' => 'tt_content', 'source' => '1,2,3']);
- class:
Ssch\TYPO3Rector\Rector\Core\Utility\RefactorRemovedMethodsFromGeneralUtilityRector
- test fixtures
Refactor removed methods from GeneralUtility.
-GeneralUtility::gif_compress();
+\TYPO3\CMS\Core\Imaging\GraphicalFunctions::gifCompress();
Remove vendor name from registerPlugin call
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
- 'TYPO3.CMS.Form',
+ 'Form',
'Formframework',
'Form',
'content-form',
);
Remove parameter colPos from methods.
$someObject = GeneralUtility::makeInstance(LocalizationRepository::class);
-$someObject->fetchOriginLanguage($pageId, $colPos, $localizedLanguage);
+$someObject->fetchOriginLanguage($pageId, $localizedLanguage);
Remove @flushesCaches annotation
/**
- * My command
- *
- * @flushesCaches
+ * My Command
*/
public function myCommand()
{
-}
+}
Remove method call init from PageRepository
-$repository = GeneralUtility::makeInstance(PageRepository::class);
-$repository->init(true);
+$repository = GeneralUtility::makeInstance(PageRepository::class);
Remove method call initTemplate from TypoScriptFrontendController
-$tsfe = GeneralUtility::makeInstance(TypoScriptFrontendController::class);
-$tsfe->initTemplate();
+$tsfe = GeneralUtility::makeInstance(TypoScriptFrontendController::class);
Remove @internal annotation from classes extending \TYPO3\CMS\Extbase\Mvc\Controller\CommandController
-/**
- * @internal
- */
class MyCommandController extends CommandController
{
}
- class:
Ssch\TYPO3Rector\Rector\Backend\Controller\RemovePropertiesFromSimpleDataHandlerControllerRector
- test fixtures
Remove assignments or accessing of properties prErr and uPT from class SimpleDataHandlerController
final class MySimpleDataHandlerController extends SimpleDataHandlerController
{
public function myMethod()
{
- $pErr = $this->prErr;
- $this->prErr = true;
- $this->uPT = true;
}
}
Use method getControllerExtensionName from $request property instead of removed property $extensionName
class MyCommandController extends CommandController
{
public function myMethod()
{
- if($this->extensionName === 'whatever') {
+ if($this->request->getControllerExtensionName() === 'whatever') {
}
- $extensionName = $this->extensionName;
+ $extensionName = $this->request->getControllerExtensionName();
}
}
Use method getBackendUserAuthentication instead of removed property $userAuthentication
class MyCommandController extends CommandController
{
public function myMethod()
{
- if($this->userAuthentication !== null) {
+ if($this->getBackendUserAuthentication() !== null) {
}
}
}
- class:
Ssch\TYPO3Rector\Rector\Core\Utility\RemoveSecondArgumentGeneralUtilityMkdirDeepRector
- test fixtures
Remove second argument of GeneralUtility::mkdir_deep()
-GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/', 'myfolder');
+GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/' . 'myfolder');
Replaces defined classes by new ones.
services:
Ssch\TYPO3Rector\Rector\Migrations\RenameClassMapAliasRector:
oldClassAliasMap: config/Migrations/Code/ClassAliasMap.php
↓
namespace App;
-use t3lib_div;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
function someFunction()
{
- t3lib_div::makeInstance(\tx_cms_BackendLayout::class);
+ GeneralUtility::makeInstance(\TYPO3\CMS\Backend\View\BackendLayoutView::class);
}
Turns method call names to new ones from new Environment API.
-Bootstrap::usesComposerClassLoading();
-GeneralUtility::getApplicationContext();
-EnvironmentService::isEnvironmentInCliMode();
+Environment::getContext();
+Environment::isComposerMode();
+Environment::isCli();
- class:
Ssch\TYPO3Rector\Rector\IndexedSearch\Controller\RenamePiListBrowserResultsRector
- test fixtures
Rename pi_list_browseresults calls to renderPagination
-$this->pi_list_browseresults
+$this->renderPagination
Replace old annotation by new one
services:
Ssch\TYPO3Rector\Rector\Annotation\ReplaceAnnotationRector:
$oldToNewAnnotations:
transient: TYPO3\CMS\Extbase\Annotation\ORM\Transient
↓
/**
- * @transient
+ * @TYPO3\CMS\Extbase\Annotation\ORM\Transient
*/
-private $someProperty;
+private $someProperty;
Substitute $GLOBALS['PARSETIME_START'] with round($GLOBALS['TYPO3_MISC']['microtime_start'] * 1000)
-$parseTime = $GLOBALS['PARSETIME_START'];
+$parseTime = round($GLOBALS['TYPO3_MISC']['microtime_start'] * 1000);
Substitute TemplateService->splitConfArray() with TypoScriptService->explodeConfigurationForOptionSplit()
-$splitConfig = GeneralUtility::makeInstance(TemplateService::class)->splitConfArray($conf, $splitCount);
+$splitConfig = GeneralUtility::makeInstance(TypoScriptService::class)->explodeConfigurationForOptionSplit($conf, $splitCount);
Substitute $GLOBALS['TT'] method calls
-$GLOBALS['TT']->setTSlogMessage('content');
+GeneralUtility::makeInstance(TimeTracker::class)->setTSlogMessage('content');
Use ActionController class instead of AbstractController if used
-class MyController extends AbstractController
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+
+class MyController extends ActionController
{
}
Use $fileObject->getMetaData()->get() instead of $fileObject->_getMetaData()
$fileObject = new File();
-$fileObject->_getMetaData();
+$fileObject->getMetaData()->get();
Turns \TYPO3\CMS\Extbase\Utility\TypeHandlingUtility::hex2bin calls to native php hex2bin
-\TYPO3\CMS\Extbase\Utility\TypeHandlingUtility::hex2bin("6578616d706c65206865782064617461");
+hex2bin("6578616d706c65206865782064617461");
Use PackageManager API instead of $GLOBALS['TYPO3_LOADED_EXT']
-$extensionList = $GLOBALS['TYPO3_LOADED_EXT'];
+$extensionList = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
- class:
Ssch\TYPO3Rector\Rector\Fluid\ViewHelpers\UseRenderingContextGetControllerContextRector
- test fixtures
Get controllerContext from renderingContext
class MyViewHelperAccessingControllerContext extends AbstractViewHelper
{
- protected $controllerContext;
-
public function render()
{
- $controllerContext = $this->controllerContext;
+ $controllerContext = $this->renderingContext->getControllerContext();
}
}
- class:
Ssch\TYPO3Rector\Rector\Backend\Utility\UseTypo3InformationForCopyRightNoticeRector
- test fixtures
Migrate the method BackendUtility::TYPO3_copyRightNotice() to use Typo3Information API
-$copyright = BackendUtility::TYPO3_copyRightNotice();
+$copyright = GeneralUtility::makeInstance(Typo3Information::class)->getCopyrightNotice();
Turns properties with @validate
to properties with @TYPO3\CMS\Extbase\Annotation\Validate
/**
- * @validate NotEmpty
- * @validate StringLength(minimum=0, maximum=255)
+ * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
+ * @TYPO3\CMS\Extbase\Annotation\Validate("StringLength", options={"minimum": 3, "maximum": 50})
*/
private $someProperty;