getting started with extbase
DESCRIPTION
ExtBase starting tutorial from TYPO3 camp Regensburg #t3crTRANSCRIPT
![Page 1: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/1.jpg)
Starting with ExtBase
![Page 2: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/2.jpg)
Grundaufbau ExtBase/Fluid Model: Product
• Title • Price
Repository • findAll
• findByProperty
Controller • List • Show
Fluid Template • List
Fluid Template • Show
![Page 3: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/3.jpg)
Grundaufbau ExtBase/Fluid
Model
Controller
Fluid Template
public function getTitle() { return $this->title; }
public function listAction() { $products = $this->productRepository->findAll(); $this->view->assign('products', $products); }
<f:for each="{products}" as="product"> <tr> <td> <f:link.action action="show" arguments="{product : product}"> {product.title} </f:link.action> </td> </tr> </f:for>
![Page 4: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/4.jpg)
ViewHelper
Fluid Template {namespace as=TYPO3\AsViewhelper\ViewHelpers} <f:for each="{products}" as="product"> <tr> <td> <f:link.action action="show" arguments="{product : product}"> <as:uppercase value="{product.title}" /> </f:link.action> </td> </tr> </f:for>
ViewHelper class UppercaseViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper { public function render($value) { return strtoupper($value); } }
![Page 5: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/5.jpg)
Extension Builder
![Page 6: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/6.jpg)
Extension Builder
![Page 7: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/7.jpg)
Extension Builder: Relations
• Hauptobjekt: Product – aggregate root
• Untertabellen: Color
• Relations: Drag & Drop mit dem Kreis
• More->Type: 1:1, 1:n, n:1, n:m
![Page 8: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/8.jpg)
Verzeichnisstruktur
- Classes --- Controller --- Domain --- ViewHelpers - Configuration --- FlexForms --- TCA --- TypoScript - Resources --- Private ----- Templates --- Public ----CSS ----JS
![Page 9: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/9.jpg)
Konventionen
• phpDoc vor Funktionen
• Camel-Case, Lower-Camel-Case, Unterstrich,…?
– Class: AsDemoExtbase
– Variable: asDemoExtbase
– Datenbank: as_demo_extbase
![Page 10: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/10.jpg)
Datenbank: Repository
• Sehr viele Default-Funktionen: • findAll = SELECT * FROM table • findByName($val) =
SELECT * FROM table where name like „$val • findOneByArticleNo($id)
SELECT … limit 1 • Add, remove, update, replace, • $query->createQuery; $query->matching(),
constraints, $query->execute • SQL: $query->statement(„SELECT ….“)
![Page 11: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/11.jpg)
ObjectManager
• PHP: new TYPO3: t3lib_div::createInstance
• Extbase: Singleton, DependencyInjection
• objectManager->get (Controller, Repository)
• objectManager->create (Model), danach im Repistory: $this->add($obj)
$prod=$this->objectManager->create
('TYPO3\\Asextbasedemo1\\Domain\\Model\\Product');
$prod->setTitle("AutoCreated");
$this->productRepository->add($prod);
2 Slashes in Namespace Path!
![Page 12: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/12.jpg)
Nice to know
• piBased: $this->pi_getLL('languagekey')
• \TYPO3\CMS\Extbase\Utility\LocalizationUtility::tr
anslate('languagekey', $extensionName)
(extensionName: Ordnername in typo3conf/ext)
![Page 13: Getting started with ExtBase](https://reader033.vdocuments.us/reader033/viewer/2022052906/558cde2ed8b42a085a8b45cf/html5/thumbnails/13.jpg)
Links
• Tutorial: http://www.typo3lexikon.de/typo3-tutorials/extensions/fluid.html
• Extbase Buch Kurfürst: http://docs.typo3.org/typo3cms/ExtbaseFluidBook/
• Mittwald: ExtBase Referenz PDF https://www.mittwald.de/typo3-dokumentation/
• Tips: http://t3n.de/magazin/zehn-tipps-tricks-extbase-fluid-227639/
• Namespaces: http://www.speedprogs.de/anleitungen/detailansicht/extension-entwicklung-mit-namespaces.html