Slide 1

Slide 1 text

EXTENSION DEVELOPMENT WITH EXTBASE TYPO3 [email protected] @typo3 August 2nd, 2019 Karlsruhe, Germany

Slide 2

Slide 2 text

OLIVER HADER  Research & Development  Security Team Lead  Darth Hader @ohader [email protected]

Slide 3

Slide 3 text

BENJAMIN KOTT  Developer Advocate  Consultant  UI/UX Lead @benjaminkott [email protected]

Slide 4

Slide 4 text

1. Introduction 2. Persistence Variations 3. Software Architecture 4. Caching 5. Bonus+

Slide 5

Slide 5 text

EXTBASE IN A NUTSHELL

Slide 6

Slide 6 text

EXTBASE LAYERS Application Layer Repository query builder Object Relational Mapping model reconstitution Services reusable processing Infrastructure Layer View output rendering Validation controller / domain Domain Model business logic Schema Doctrine DBAL Relation Handling (basically based on TCA) Behavior (often mixed in controllers) Extbase Routing Property Mapping model reconstitution View Helpers output functions Controller orchestration & delegation TYPO3 Routing Invocation CLI request HTTP request Domain Layer Presentation Layer Application Dispatcher symfony/routing plugin configuration TypoScript settings Orchestration controller actions action arguments domain invocation infrastructure invocation presentation invocation Templating Engine Fluid, Twig, Blade, … HTML, XML, JSON, …

Slide 7

Slide 7 text

EXTBASE SECURITY ASPECTS  Extbase application is "accessible" by everybody  no user or permission management in frontend  controller-action can be called directly .../?tx[controller]=User&tx[action]=delete&…  access control must be done individually  either by using dedicated plugins & frontend groups  or in each controller, authorizing actins (suggested)

Slide 8

Slide 8 text

This "protection" just concerns the visual output

Slide 9

Slide 9 text

PERSISTENCE

Slide 10

Slide 10 text

 Kickstarted with Extension Builder  Good for getting started  Must be adjusted

Slide 11

Slide 11 text

CAR RENTAL EXAMPLE # vin: string # color: string # brand: Brand # charge: Charge # tires: Tire[] # rentals: Rental[] # maintenances: Maintenance[] # images: FileReference[] <> Car + get…() + set…() # startDate: DateTime # endDate: DateTime # returnDate: DateTime # customer: Customer # agent: Agent # car: Car Rental + get…() + set…() # name: string Brand + get…() + set…() # treadDepth: float # pressure: float Tire + get…() + set…() # issueDate: DateTime # mechanic: Mechanic # car: Car Maintenance + get…() + set…() # name: string # price: float Charge + get…() + set…() # employeeNumber <> Employee + get…() + set…() Customer Mechanic Agent # username # password # firstName # lastName # email # telephone # … Extbase\…\FrontendUser + get…() + set…() 1 1 1 1 1 n 1 1 1 1 1 1 1 1 n n # uidLocal: int Extbase\…\FileReference + getOriginalResource(): FileReference # originalResource: ResourceInterface Extbase\…\AbstractFileFolder + getOriginalResource(): ResourceInterface

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

 LazyLoading 1:n (ObjectStorage)  LazyLoading 1:1 (LazyLoadingProxy)  and current drawbacks in implementation

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

 Using Doctrine DBAL QueryBuilder  Using custom query statements  In order to be more flexible  Submitted data must be escaped/casted (security)

Slide 16

Slide 16 text

 Omitting ORM layer, retrieve raw-data (array)  Pros & Cons of working with arrays or objects

Slide 17

Slide 17 text

SOFTWARE ARCHITECTURE

Slide 18

Slide 18 text

CAR RENTAL EXAMPLE # vin: string # color: string # brand: Brand # charge: Charge # tires: Tire[] # rentals: Rental[] # maintenances: Maintenance[] # images: FileReference[] <> Car + get…() + set…() # startDate: DateTime # endDate: DateTime # returnDate: DateTime # customer: Customer # agent: Agent # car: Car Rental + get…() + set…() # name: string Brand + get…() + set…() # treadDepth: float # pressure: float Tire + get…() + set…() # issueDate: DateTime # mechanic: Mechanic # car: Car Maintenance + get…() + set…() # name: string # price: float Charge + get…() + set…() # employeeNumber <> Employee + get…() + set…() Customer Mechanic Agent # username # password # firstName # lastName # email # telephone # … Extbase\…\FrontendUser + get…() + set…() 1 1 1 1 1 n 1 1 1 1 1 1 1 1 n n # uidLocal: int Extbase\…\FileReference + getOriginalResource(): FileReference # originalResource: ResourceInterface Extbase\…\AbstractFileFolder + getOriginalResource(): ResourceInterface

Slide 19

Slide 19 text

CAR RENTAL EXAMPLE

Slide 20

Slide 20 text

CAR RENTAL EXAMPLE PRO  Car aggregate root  Everything available  Single entry point  Comfortable CON  Lots of DB queries  Memory footprint  Performance impact  Growing amount of associations

Slide 21

Slide 21 text

CAR RENTAL EXAMPLE – BOUNDED CONTEXTS  Separate into contexts/scenarios  Rental  Presenting cars  Handling reservations & rentals  Handle booking & pricing  Maintenance  Maintaining car  Check tires  Document actions

Slide 22

Slide 22 text

CAR RENTAL EXAMPLE – BOUNDED CONTEXTS Extbase Maintenance Common Rental # vin: string # color: string # brand: Brand # tires: Tire[] # maintenances: Maintenance[] <> Maintenance\Car + get…() + set…() # startDate: DateTime # endDate: DateTime # returnDate: DateTime # customer: Customer # agent: Agent # car: Car Rental + get…() + set…() # name: string Brand + get…() + set…() # treadDepth: float # pressure: float Tire + get…() + set…() # issueDate: DateTime # mechanic: Mechanic # car: Car Maintenance + get…() + set…() # name: string # price: float Charge + get…() + set…() # employeeNumber <> Employee + get…() + set…() Customer Mechanic Agent # username # password # firstName # lastName # email # telephone # … Extbase\…\FrontendUser + get…() + set…() 1 1 1 1 1 1 1 1 n n # uidLocal: int Extbase\…\FileReference + getOriginalResource(): FileReference # originalResource: ResourceInterface Extbase\…\AbstractFileFolder + getOriginalResource(): ResourceInterface # vin: string # color: string # brand: Brand # rentals: Rental[] # images: FileReference[] <> Rental\Car + get…() + set…() 1 1 1 1 n 1 1 1

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

CAR RENTAL EXAMPLE – BOUNDED CONTEXTS

Slide 27

Slide 27 text

CAR RENTAL EXAMPLE - INHERITANCE  Agent extends Employee extends FrontendUser  Inheritance tree is probably too large  Superfluous information is retrieved  Only customerId, employeeId, … are required  Full FrontendUser used for authentication (In this case: username & password in View)

Slide 28

Slide 28 text

CAR RENTAL EXAMPLE - INHERITANCE Extbase Maintenance Common Rental # vin: string # color: string # brand: Brand # tires: Tire[] # maintenances: Maintenance[] <> Maintenance\Car + get…() + set…() # startDate: DateTime # endDate: DateTime # returnDate: DateTime # customer: Customer # agent: Agent # car: Car Rental + get…() + set…() # name: string Brand + get…() + set…() # treadDepth: float # pressure: float Tire + get…() + set…() # issueDate: DateTime # mechanic: Mechanic # car: Car Maintenance + get…() + set…() # name: string # price: float Charge + get…() + set…() # frontendUserId: int # customerId: string Customer + get…() + set…() # frontendUserId: int # employeeNumber: string Mechanic + get…() + set…() # frontendUserId: int # employeeNumber: string Agent + get…() + set…() # username # password # firstName # lastName # email # telephone # … Extbase\…\FrontendUser + get…() + set…() 1 1 1 1 1 1 1 1 n n # uidLocal: int Extbase\…\FileReference + getOriginalResource(): FileReference # originalResource: ResourceInterface Extbase\…\AbstractFileFolder + getOriginalResource(): ResourceInterface # vin: string # color: string # brand: Brand # rentals: Rental[] # images: FileReference[] <> Rental\Car + get…() + set…() 1 1 1 1 n 1 1 1 FrontendUserService + retrieveUserById(int $id)

Slide 29

Slide 29 text

CAR RENTAL EXAMPLE – PLUGIN & CONTROLLER ORCHESTRATION  Using Extbase plugin configuration  Should only contain required controller-actions  Permissions on plugin level (frontend groups)  Avoids potential side effects

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

PROBLEMS  Every request fetches data from an external endpoint  Reaching API-Limits quickly  Probably gets expensive  Bonus: Slow  Question: How often does the weather change?

Slide 38

Slide 38 text

CACHING FRAMEWORK

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

SOLUTION  Minimum effort / high impact  System only fetches new data after lifetime expired  Limited requests to API  Lot´s cheaper  Bonus: Faster  Answer: 30 minutes should be fine

Slide 44

Slide 44 text

CACHING FRAMEWORK  The caching framework is really easy to use.  If you have a lot of requests fetching the same data, you can fetch them once, prepare them and save them for later.  Keep in mind that cache CAN have a lifetime.  If you do not set a lifetime you need to take care of invalidation

Slide 45

Slide 45 text

SHIPPING FORMS TO THE UNKNOWN

Slide 46

Slide 46 text

Form Template Flash Message Template Error Message Template No validation error at the property EXT:BLOG 9.1

Slide 47

Slide 47 text

EVERY CHANGE TO THESE TEMPLATES WILL BREAK SOMEONE'S INSTANCE

Slide 48

Slide 48 text

REQUIREMENTS  Needs to validate input  Needs to show validation errors on property  Needs to persist data  Needs to be translatable  Needs to be dynamically created  Needs to add features through configuration  Needs to send notifications  Needs to be extendable in the future  Needs to work in every frontend environment

Slide 49

Slide 49 text

Extbase EXT:form Validate Input Validation Error on Property Persist Data Dynamically Created Translateable Notifications Yes custom optional Yes Hard custom Yes Yes optional Yes Easy custom FEATURE COMPARISON

Slide 50

Slide 50 text

Extbase EXT:form Extendable API Frontend Independent Custom Templates Result Hard No Yes 2 Easy Yes No 7 FEATURE COMPARISON

Slide 51

Slide 51 text

Local Closed Disqus

Slide 52

Slide 52 text

Local

Slide 53

Slide 53 text

FormFactory & FormFinisher

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

316 ADDITIONS 276 DELETIONS [!!!][TASK] USE TYPO3 FORM FRAMEWORK FOR COMMENT FORM 407A2AF699961F3C2726204F4A6C49E22E162A07

Slide 63

Slide 63 text

QUESTIONS? OLIVER HADER & BENJAMIN KOTT @ohader & @benjaminkott [email protected]

Slide 64

Slide 64 text

THANK YOU