PiBase Updates

50 %
50 %
Information about PiBase Updates

Published on June 12, 2016

Author: schmutt

Source: slideshare.net

1. PiBase Updates What about piBased Extensions in TYPO3 6.2,7.6 and future versions

2. Will it be removed? • Nope! There are no plans to remove piBased support from TYPO3 • Its some search&replace of class names and functions to run a piBased extension in 6.2, 7.6 and even 8LTS • but you will have to check for PHP version errors as well (7.6 and 8 run on PHP7), as well as other environment dependencies I have heard they will remove piBase support with the next TYPO3 update?

3. Use piBased Extension in 6.2 and 7.6 Solution 1: Compatibility Layer • Install extension: compatibility6 • Problem: – still some errors can happen – performance issues • I never used it, as Solution 2 is easier

4. Use piBased Extension in 6.2 and 7.6 Solution 2: Make necessary changes • ext_emconf.php: Update TYPO3 Version Number (or accept the installation warning) • open PHP error log: tail -f /var/log/apache2/error.log • install Extension and remove errors: – search/replace the known errors – google other error messages: it is all known and fixed already

5. Known piBased errors Error Solution Call to undefined method loadTCA Remove in ext_tables.php: t3lib_div::loadTCA("tt_content"); in ext_tables.php Failed opening required 'PATH_tslibclass.tslib_pibase.php' remove require statements for TYPO3 core files: require_once(PATH_tslib.’class.tslib_pibase.php’); Failed opening required 'class.tslib_content.php' replace extends class: Replace 'myclass extends tslib_pibase' with 'myclass extends TYPO3CMSFrontendPluginAbstractPlugin' Class 't3lib_div' not found in... replace "t3lib_div" with TYPO3CMSCoreUtilityGeneralUtility Class 't3lib_extMgm' not found in... replace "t3lib_extMgm" with TYPO3CMSCoreUtilityExtensionManagementUtility More Info: http://blog.scwebs.in/typo3/make-pibase-extension-compatible-to-typo3-6-2-x

6. Mapping old and new classes • Mapping of all old and new class names: https://docs.typo3.org/typo3cms/CoreApiRef erence/6.2/ApiOverview/Namespaces/ • Scroll down to "ClassAliasMap" • This can also be found in a 6.2 source in this file: typo3/sysext/core/Migrations/Code/ClassAlias Map.php

7. Namespaces • without namespaces, unique class names were like this: class Tx_MyExtensionName_Controller_ContactController extends Tx_Extbase_MVC_Controller_ActionController {...} • with Namespace, it is like this: namespace VendorMyExtensionNameController; class ContactController extends TYPO3CMSExtbaseMvcControllerActionController {...} • shortcut for long namespaces: use TYPO3CMSCoreUtilityGeneralUtility; GeneralUtility::underscoredToUpperCamelCase($var); • Learn more about Namespaces – in PHP: http://php.net/manual/en/language.namespaces.php – in TYPO3: https://docs.typo3.org/typo3cms/CoreApiReference/latest/ ApiOverview/Namespaces/

8. PiBase to ExtBase Side-by-Side upgrade code from piBase to ExtBase

9. Folder Structure: unchanged What piBased ExtBase required changes Extension Manager Configuration ext_emconf.php ext_emconf.php x no Extension icon ext_icon.gif ext_icon.gif x no Configuration ext_localconf.php ext_localconf.php same as before but new function calls Configuration ext_tables.php ext_tables.php same as before but new function calls Database SQL Statements ext_tables.sql ext_tables.sql no

10. Folder Structure: moved What piBased ExtBase changes TCA tca.php Configuration/TCA/*.php no - but 1 File per Model FlexForms flexforms.xml Configuration/FlexForms/ flexforms.xml no Typoscript ext_typoscript_ setup.txt ext_typoscript_ constants.txt Configuration/TypoScript/* no Template pi1/ template.html Resources/Private/Layouts Resources/Private/Partials Resources/Private/Templates yes: Fluid Templates Language pi1/ locallang.xml Resources/Private/Language /locallang.xml No (but there is a new .xlf format) Assets (img, css, js) somewhere Resources/Public/* no

11. Folder Structure: changes What piBased ExtBase changes Code pi1, pi2,... Folder Classes MVC Pattern Template pi1/ template.html Resources/Private/Layouts Resources/Private/Partials Resources/Private/Templates Fluid Templates Documentation doc/ manual.sxw Documentation/Manual RESTful Syntax

12. Example: DCE

13. Hello World! • piBase: – tx_extname_pi1->main(): $message = 'Hello World!'; $output = marker replace ###MESSAGE### with $message return $this->pi_wrapInBaseClass($output); – template.html <h1>###MESSAGE###</h1> • ExtBase: – ItemController->mainAction(): $message = 'Hello World!'; $this->view->assign('message',$message); – View → MainAction.html <h1>{message}</h1>

14. MVC: Controller and Actions piBased: use GET Parameter to controll program flow switch($param) { case 'list': ... case 'show': ... default: … } Ext Base: listAction, showAction, dashboardAction www.domain.de?tx_myext[action]=list& tx_myext[controller]=Product Instead of pi1, pi2, pi3, pi4: use now a logical structure in Controller and Actions

15. MVC: Views und Fluid Replaces the old marker system Fluid is a template language like Smarty or Twig https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewH elper

16. MVC: Model • Classes folder contains: – Controller – Domain • Model: Data Objects with getter and setter methods • Repository: Database functions – other folders - as much as you want Here it is possible to reuse some important classes from your piBase Extension. Check "autoload" syntax for include

17. Important Functions piBased ExtBase $this->piVars $this->request->getArguments(); new classname $this->objectManager->get('classname'); TypoScript Parameter plugin.tx_myext.settings { param1 = 12345 } $this->settings['param1'] Redirect Redirect auf showAction im gleichen Controller: $this->redirect('show') weitere Parameter für andere Controller, etc. Links ($this->pi_getPageLink, pi_linkToPage,...) $this->uriBuilder->reset(); $link = $this->uriBuilder- >uriFor('show',$params); viele weitere Funktionen in der UriBuilder Klasse

18. Important Functions piBased ExtBase $this->pi_getLL TYPO3CMSExtbaseUtilityLocalizationUtility ::translate('your_label_key','your_extensionNa me'); t3lib_div und t3lib_utility Funktionen TYPO3CMSCoreUtilityGeneralUtility https://docs.typo3.org/typo3cms/CoreApiRefer ence/ApiOverview/MainClasses/UsefulFunctio ns/Index.html t3lib_extMgm TYPO3CMSCoreUtilityExtensionManageme ntUtility $this->cObj 1) Check if there is already ExtBase solution for your Problem 2) $this->configurationManager- >getContentObject();

19. Language Handling • Files moved to: Resources/Private/Language/locallang.xml or .xlf • in View: Fluid Tag <f:translate key="your_label_key" /> • piBased: $this->pi_getLL('your_label_key') • ExtBase: TYPO3CMSExtbaseUtilityLocalizationUtil ity::translate('your_label_key','your_exte nsionName');

Add a comment