Getting started with ExtBase
-
Upload
schmutt -
Category
Technology
-
view
1.420 -
download
0
description
Transcript of Getting started with ExtBase
Starting with ExtBase
Grundaufbau ExtBase/Fluid Model: Product
• Title • Price
Repository • findAll
• findByProperty
Controller • List • Show
Fluid Template • List
Fluid Template • Show
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>
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); } }
Extension Builder
Extension Builder
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
Verzeichnisstruktur
- Classes --- Controller --- Domain --- ViewHelpers - Configuration --- FlexForms --- TCA --- TypoScript - Resources --- Private ----- Templates --- Public ----CSS ----JS
Konventionen
• phpDoc vor Funktionen
• Camel-Case, Lower-Camel-Case, Unterstrich,…?
– Class: AsDemoExtbase
– Variable: asDemoExtbase
– Datenbank: as_demo_extbase
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 ….“)
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!
Nice to know
• piBased: $this->pi_getLL('languagekey')
• \TYPO3\CMS\Extbase\Utility\LocalizationUtility::tr
anslate('languagekey', $extensionName)
(extensionName: Ordnername in typo3conf/ext)
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