Last active
December 21, 2020 18:37
-
-
Save daKmoR/7490199 to your computer and use it in GitHub Desktop.
Converts a TYPO3 CMS extension from using non-namespaced names to namespaced names (used since TYPO3 6.0) Usage:
just copy the file inside your extension and call it from the shell
./toNamespaces.sh It replaces MOST of the non-namespaced calls... but it's by far not perfect, so pls handle with care and ALWAYS look what it changed before commitin…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
search=() | |
replace=() | |
# 0 | |
search+=("'tx_cms_layout'") | |
replace+=("'TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutView'") | |
search+=("Facets_ChildNodeAccessInterface") | |
replace+=("Facets\ChildNodeAccessInterface") | |
search+=("Tx_Fluid_Core_Parser_SyntaxTree_TextNode") | |
replace+=("\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\TextNode") | |
search+=("Tx_Fluid_ViewHelpers_TranslateViewHelper") | |
replace+=("\TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper") | |
search+=("Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper") | |
replace+=("\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper") | |
search+=("'Tx_Fluid_View_StandaloneView'") | |
replace+=("'TYPO3\\\\CMS\\\\Fluid\\\\View\\\\StandaloneView'") | |
search+=("Tx_Fluid_View_StandaloneView") | |
replace+=("\TYPO3\CMS\Fluid\View\StandaloneView") | |
search+=("Tx_Fluid_Core_Parser_SyntaxTree_BooleanNode") | |
replace+=("\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode") | |
search+=("'Tx_Fluid_Core_Widget_") | |
replace+=("'TYPO3\\\\CMS\\\\Fluid\\\\Core\\\\Widget\\\\") | |
search+=("Tx_Fluid_Core_Widget_") | |
replace+=("\TYPO3\CMS\Fluid\Core\Widget\\") | |
search+=("Tx_Fluid_View_AbstractTemplateView::") | |
replace+=("\TYPO3\CMS\Fluid\View\AbstractTemplateView::") | |
search+=("'Tx_Fluid_Core_Rendering_") | |
replace+=("'TYPO3\\\\CMS\\\\Fluid\\\\Core\\\\Rendering\\\\") | |
search+=("Tx_Fluid_Core_Rendering_") | |
replace+=("\TYPO3\CMS\Fluid\Core\Rendering\\") | |
search+=("Tx_Fluid_View_TemplateView") | |
replace+=("\TYPO3\CMS\Fluid\View\TemplateView") | |
search+=("Tx_Fluid_Core_Parser_TemplateParser::") | |
replace+=("\TYPO3\CMS\Fluid\Core\Parser\TemplateParser::") | |
search+=("'Tx_Fluid_Core_ViewHelper_") | |
replace+=("'TYPO3\\\\CMS\\\\Fluid\\\\Core\\\\ViewHelper\\\\") | |
search+=("Tx_Fluid_Core_ViewHelper_") | |
replace+=("\TYPO3\CMS\Fluid\Core\ViewHelper\\") | |
search+=("'Tx_Extbase_Domain_Repository_FrontendUserRepository'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Repository\\\\FrontendUserRepository'") | |
search+=("Tx_Extbase_Domain_Repository_FrontendUserRepository") | |
replace+=("\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository") | |
search+=("'Tx_Extbase_MVC_Dispatcher'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Dispatcher'") | |
search+=("Tx_Extbase_MVC_Dispatcher") | |
replace+=("\TYPO3\CMS\Extbase\Mvc\Dispatcher") | |
search+=("instanceof Tx_Extbase_Persistence_LazyObjectStorage") | |
replace+=("instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage") | |
search+=("extends Tx_Fluid_Core_ViewHelper_AbstractConditionViewHelper") | |
replace+=("extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper") | |
search+=("Tx_Extbase_DomainObject_DomainObjectInterface") | |
replace+=("\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface") | |
search+=("extends Tx_Extbase_DomainObject_AbstractEntity") | |
replace+=("extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity") | |
search+=("Tx_Extbase_Utility_Debugger") | |
replace+=("\TYPO3\CMS\Extbase\Utility\DebuggerUtility") | |
search+=("Tx_Extbase_Domain_Model_FrontendUser") | |
replace+=("\TYPO3\CMS\Extbase\Domain\Model\FrontendUser") | |
search+=("Tx_Extbase_Persistence_Query") | |
replace+=("\TYPO3\CMS\Extbase\Persistence\Generic\Query") | |
search+=("extends Tx_Extbase_MVC_Controller_ActionController") | |
replace+=("extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController") | |
search+=("new t3lib_clipboard") | |
replace+=("new \TYPO3\CMS\Backend\Clipboard\Clipboard") | |
search+=("'Tx_Extbase_MVC_Web_Request'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Web\\\\Request'") | |
search+=("Tx_Extbase_MVC_Web_Request") | |
replace+=("\TYPO3\CMS\Extbase\Mvc\Web\Request") | |
search+=("t3lib_extMgm::") | |
replace+=("\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::") | |
search+=("Tx_Extbase_Utility_Extension::") | |
replace+=("\TYPO3\CMS\Extbase\Utility\ExtensionUtility::") | |
search+=("implements t3lib_extTables_PostProcessingHook") | |
replace+=("implements \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface") | |
search+=("\t3lib_div::") | |
replace+=("\TYPO3\CMS\Core\Utility\GeneralUtility::") | |
search+=("t3lib_div::") | |
replace+=("\TYPO3\CMS\Core\Utility\GeneralUtility::") | |
search+=("'Tx_Extbase_Object_ObjectManager'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Object\\\\ObjectManager'") | |
search+=("Tx_Extbase_Object_ObjectManager") | |
replace+=("\TYPO3\CMS\Extbase\Object\ObjectManager") | |
search+=("Tx_Extbase_Object_ObjectManagerInterface") | |
replace+=("\TYPO3\CMS\Extbase\Object\ObjectManagerInterface") | |
search+=("'Tx_Extbase_Configuration_ConfigurationManagerInterface'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Configuration\\\\ConfigurationManagerInterface'") | |
search+=("Tx_Extbase_Configuration_ConfigurationManagerInterface") | |
replace+=("\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface") | |
search+=("Tx_Extbase_Reflection_Service") | |
replace+=("\TYPO3\CMS\Extbase\Reflection\ReflectionService") | |
search+=("'Tx_Extbase_Persistence_Mapper_DataMapFactory'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\Generic\\\\Mapper\\\\DataMapFactory'") | |
search+=("'t3lib_flexformtools'") | |
replace+=("'TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\FlexForm\\\\FlexFormTools'") | |
search+=("'t3lib_FlashMessage'") | |
replace+=("'TYPO3\\\\CMS\\\\Core\\\\Messaging\\\\FlashMessage'") | |
search+=("t3lib_FlashMessage") | |
replace+=("\TYPO3\CMS\Core\Messaging\FlashMessage") | |
search+=("'Tx_Extbase_MVC_Controller_ControllerContext'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Controller\\\\ControllerContext'") | |
search+=("Tx_Extbase_MVC_Controller_ControllerContext") | |
replace+=("\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext") | |
search+=("implements t3lib_Singleton") | |
replace+=("implements \TYPO3\CMS\Core\SingletonInterface") | |
search+=("t3lib_BEfunc::") | |
replace+=("TYPO3\CMS\Backend\Utility\BackendUtility::") | |
search+=("new t3lib_TSparser") | |
replace+=("new \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser") | |
search+=("new t3lib_matchCondition_backend") | |
replace+=("new \TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher") | |
search+=("'t3lib_tsparser_ext'") | |
replace+=("'TYPO3\\\\CMS\\\\Core\\\\TypoScript\\\\ExtendedTemplateService'") | |
search+=("t3lib_iconWorks::") | |
replace+=("\TYPO3\CMS\Backend\Utility\IconUtility::") | |
search+=("'t3lib_pageSelect'") | |
replace+=("'TYPO3\\\\CMS\\\\Frontend\\\\Page\\\\PageRepository'") | |
search+=("@var t3lib_pageSelect") | |
replace+=("@var \TYPO3\CMS\Frontend\Page\PageRepository") | |
search+=("@return t3lib_pageSelect") | |
replace+=("@return \TYPO3\CMS\Frontend\Page\PageRepository") | |
search+=("new t3lib_pageSelect") | |
replace+=("new \TYPO3\CMS\Frontend\Page\PageRepository") | |
search+=("'t3lib_TCEmain'") | |
replace+=("'TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\DataHandler'") | |
search+=("t3lib_TCEmain $") | |
replace+=("\TYPO3\CMS\Core\DataHandling\DataHandler $") | |
search+=("@param t3lib_TCEmain") | |
replace+=("@param \TYPO3\CMS\Core\DataHandling\DataHandler") | |
search+=("@return t3lib_TCEmain") | |
replace+=("@return \TYPO3\CMS\Core\DataHandling\DataHandler") | |
search+=("'t3lib_TCEforms'") | |
replace+=("'TYPO3\\\\CMS\\\\Backend\\\\Form\\\\FormEngine'") | |
search+=("@param t3lib_TCEforms") | |
replace+=("@param \TYPO3\CMS\Backend\Form\FormEngine") | |
search+=("extends Tx_Extbase_Tests_Unit_BaseTestCase") | |
replace+=("extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase") | |
search+=("Tx_Extbase_Reflection_ObjectAccess::") | |
replace+=("\TYPO3\CMS\Extbase\Reflection\ObjectAccess::") | |
search+=("'Tx_Extbase_Persistence_ObjectStorage'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage'") | |
search+=("Tx_Extbase_Persistence_ObjectStorage") | |
replace+=("\TYPO3\CMS\Extbase\Persistence\ObjectStorage") | |
search+=("Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode") | |
replace+=("\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode") | |
search+=("Tx_Extbase_MVC_View_ViewInterface") | |
replace+=("\TYPO3\CMS\Extbase\Mvc\View\ViewInterface") | |
search+=("Tx_Extbase_Utility_Localization::") | |
replace+=("\TYPO3\CMS\Extbase\Utility\LocalizationUtility::") | |
search+=("extends Tx_Extbase_MVC_Controller_ControllerInterface") | |
replace+=("extends \TYPO3\CMS\Extbase\Mvc\Controller\ControllerInterface") | |
search+=("'Tx_Extbase_Configuration_BackendConfigurationManager'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Configuration\\\\BackendConfigurationManager'") | |
search+=("Tx_Extbase_Configuration_BackendConfigurationManager") | |
replace+=("\TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager") | |
search+=("'Tx_Extbase_MVC_Web_Response'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Web\\\\Response'") | |
search+=("'Tx_Extbase_Mvc_Web_Routing_UriBuilder'") | |
replace+=("'TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Web\\\\Routing\\\\UriBuilder'") | |
search+=("Tx_Extbase_Mvc_Web_Routing_UriBuilder") | |
replace+=("\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder") | |
echo There are ${#search[@]} replacement queries. | |
# {0..77} for all | |
for i in 77 | |
do | |
# "escape \ to \\" | |
replace[$i]=${replace[$i]//\\/\\\\} | |
search[$i]=${search[$i]//\\/\\\\} | |
# escape $ to \$ | |
search[$i]=${search[$i]//$/\\$} | |
echo "$i: grep -rl \"${search[$i]}\" ./ --exclude=toNamespaces.sh --exclude-dir=".git" | xargs sed -i \"s/${search[$i]}/${replace[$i]}/g\"" | |
grep -rl "${search[$i]}" ./ --exclude=toNamespaces.sh --exclude-dir=".git" | xargs sed -i "s/${search[$i]}/${replace[$i]}/g" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment