Top Banner
Inspiring people to share T3CON09 Dallas MVC for TYPO3 4.3 with Extbase
116

MVC for TYPO3 4.3 with extbase

May 08, 2015

Download

Technology

Starting with TYPO3 4.3, a new extension framework called Extbase will be introduced. It is the backport of the MVC concepts of FLOW3. By building extensions using Extbase now, the transition and learning curve to FLOW3 will be a lot easier.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MVC for TYPO3 4.3 with extbase

Inspiring people toshare

T3CON09 Dallas

MVC for TYPO3 4.3 with Extbase

Page 3: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Abstract

The current state of the art

Core concepts - MVC and DDD

Extension building with Extbase

Outlook and conclusion

Hello world

Blog example

Persistence

Page 4: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Abstract

The current state of the art

Core concepts - MVC and DDD

Extension building with Extbase

Outlook and conclusion

Hello world

Blog example

Persistence

Page 5: MVC for TYPO3 4.3 with extbase

The current stateof the art

http://commons.wikimedia.org/wiki/File:Z%C3%BCrich_-_Seefeld_-_Heureka_IMG_1757.JPG

Page 6: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

The current state of the art

FEPlugin

Database tables

dispatches callsfetches data

renders outputResources

templatesJavaScript/CSS

imagesextends tslib_pibase TypoScript

FrontendExtension

Page 7: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

File structure

Page 8: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

A new extension: Blogging with TYPO3

Overview

define features of the new blogging application

implement the business logic

define the look and feel

take a look at security issues

modify and extend the application

Page 9: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Blog features

administrate blogs, blog posts and blog comments

list all available blogs

list all blog posts of a blog

list all comments of a blog post

allow users to post new comments

Post

Comment Tag

Blog

Page 10: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Blog business logic

dispatch method calls in tx_blog_pi1->main()

public function main($content, $conf) { $this->conf = $conf; $this->pi_setPiVarDefaults(); $this->pi_loadLL();

if ($this->piVars['postUid']) { if ($this->piVars['newComment']) { $this->storeNewComment(); } $content = $this->renderPost(); } elseif ($this->piVars['blogUid']) { $content = $this->renderBlog(); } else { $content = $this->renderListOfBlogs(); } return $this->pi_wrapInBaseClass($content);}

Page 11: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Task 1: Output a listing of blogs

fetch available blogs from database

implement a new method „renderListOfBlogs()“

protected function renderListOfBlogs() {...

$blogs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( '*', 'tx_blog_blog', 'deleted=0 AND hidden=0 AND sys_language_uid=' .

$GLOBALS['TSFE']->sys_language_uid . $this->cObj->enableFields('tx_blog_blog'), '', 'name' );

...}

Page 12: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Task 1: Output a listing of blogs

iterate through all blogs and render themprotected function renderListOfBlogs() { $template = $this->cObj->fileResource($this->conf['template']); $blogElementSubpart = $this->cObj->getSubpart($template, '###SUBPART_BLOGELEMENT###');

$blogs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(...); foreach ($blogs as $blog) { $linkParameters = array('blogUid' => $blog['uid']); $markers = array( '###BLOG_NAME###' => $blog['name'], '###BLOG_LOGO###' => $this->cImage('uploads/tx_blog/' . $blog['logo']), '###BLOG_DESCRIPTION###' => $this->pi_RTEcssText($blog['description']), '###BLOG_MORELINK###' => $this->pi_linkTP('show blog', $linkParameters, true), ); $blogElements.= $this->cObj->substituteMarkerArray($blogElementSubpart, $markers); } return $content;}

Page 13: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Task 1: Output a listing of blogs

create the template with markers and subparts

<!-- ###SUBPART_BLOGELEMENT### begin --><div class="blog element"> ###BLOG_NAME### ###BLOG_LOGO### ###BLOG_DESCRIPTION### ###BLOG_MORELINK###</div><!-- ###SUBPART_BLOGELEMENT### end -->

Page 14: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Task 2: Display a single post with its comments

implement a new method „renderListOfBlogs()“

protected function renderPost() { $post = $this->pi_getRecord('tx_blog_post', $this->piVars['postUid']); $comments = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( '*', 'tx_blog_comment', 'deleted=0 AND hidden=0 AND sys_language_uid=' .

$GLOBALS['TSFE']->sys_language_uid . ' AND post_uid=' . $this->piVars['postUid'] . ' AND post_table="tx_blog_post"' . $this->cObj->enableFields('tx_blog_comment'), '', 'date DESC' );

// fill marker arrays and substitute in template// return content

}

Page 15: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Task 3: Add a new comment to a blog post

the whole plugin is cached („USER“)

dynamic user input won‘t be handled by the rendering when cached

define uncached behavior in TypoScript

[globalVar = _POST:tx_blog_pi1|newComment = 1] plugin.tx_blog_pi1 = USER_INT[global]

Page 16: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Task 3: Add a new comment to a blog post

store new comment in database

protected function storeNewComment() { $fields = array( 'post_uid' => $this->piVars['postUid'], 'post_table' => 'tx_blog_post', 'date' => time(), 'author' => $this->piVars['author'], 'email' => $this->piVars['email'], 'content' => $this->piVars['content'], );

$GLOBALS['TYPO3_DB']->exec_INSERTquery( 'tx_blog_comment', $fields );}

Page 17: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Take a look at security issues

possibility of SQL injections

unvalidated information submitted by a user

is there really a mail address where it was expected?

are integers really integers?

malicious information submitted by a user (XSS)

is there a possibility to inject JavaScript code?

Page 18: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Security: SQL injections

unescaped or unchecked values that are transferred to the database directly

$comments = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_blog_comment','deleted=0 AND hidden=0 AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid . ' AND post_uid=' . $this->piVars['postUid'] . ' AND post_table="tx_blog_post"' .$this->cObj->enableFields('tx_blog_comment'));

with &postUid=1; INSERT INTO be_users SET ...; SELECT * FROM tx_blog_comment WHERE 1=1

SELECT * FROM tx_blog_comment WHERE post_uid=1;INSERT INTO be_users SET ...;SELECT * FROM tx_blog_comment WHERE 1=1 AND post_table=“tx_blog_post“ ...

Page 19: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Security: SQL injections

always escape or cast variables from outside

' AND post_uid=' . intval($this->piVars['postUid']) . ' AND post_table="tx_blog_post"' .

Page 20: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

The current state of the art

Modify and extend the blog application

store information on different DBMS (e.g. move from MySQL to Oracle)

are there any SQL statements that won‘t work in Oracle?

what about the length of the table names?

integrate spam protection for posting new comments

add validation to the arguments submitted by a user

integrate a PDF and RSS version of all blogs

implement new business logic for each new output format

Page 21: MVC for TYPO3 4.3 with extbase
Page 22: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Abstract

The current state of the art

Core concepts - MVC and DDD

Extension building with Extbase

Outlook and conclusion

Hello world

Blog example

Persistence

Page 23: MVC for TYPO3 4.3 with extbase

http://www.flickr.com/photos/seier/501370105/

ModelViewController

DomainDrivenDesign

Core concepts

Page 24: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts

Model View Controller

Page 25: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - MVC

Layered architecture

Domain Model (Domain Layer)

View

Controller

Page 26: MVC for TYPO3 4.3 with extbase

http://www.flickr.com/photos/bunchofpants/106465356/sizes/o/

The model is a smallrepresentation of

reality.

Page 27: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - MVC

Application domain

Example: Car rental application

Application domain contains: Car, Sales Agent, Customer, Sale, Billing

defines properties and behavior of these (real world) objects

Page 28: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - MVC

Model

Object representation of data and behavior

represents the application domain in software

FLOW3: Domain Models

Page 29: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - MVC

Model: Car rental example

Page 30: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Topictext

View

renders data for different output mediums

it‘s only about displaying data

includes all output logic

The viewrenders

data.

http://www.sxc.hu/photo/1157763

Page 31: MVC for TYPO3 4.3 with extbase

The controller steersthe data flow and triggers actions

http://www.sxc.hu/browse.phtml?f=view&id=956017

Page 32: MVC for TYPO3 4.3 with extbase

Controller

View

Model

Request Response

Page 33: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - MVC

Conclusion MVC

Model: stores data and behavior

View: renders data

Controller: connects model and view, reacts to user input

Page 34: MVC for TYPO3 4.3 with extbase
Page 35: MVC for TYPO3 4.3 with extbase

DomainDrivenDesign

http://www.sxc.hu/photo/585791

Page 36: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - Domain Driven Design

Layered architecture

Application Logic (Service Layer)

Domain Model (Domain Layer)

View

Controller

Data Mapper

Data Source Abstraction

Presentation

Domain

Data source

Page 37: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - Domain Driven Design

Layered architecture

Application Logic (Service Layer)

Domain Model (Domain Layer)

View

Controller

Data Mapper

Data Source Abstraction

Presentation

Domain

Data source

Page 38: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Principles of Domain Driven Design

Page 39: MVC for TYPO3 4.3 with extbase

Domain describes activity or business of user.

Page 40: MVC for TYPO3 4.3 with extbase

http://www.sxc.hu/photo/59950

Focus

on the

Domain

Page 41: MVC for TYPO3 4.3 with extbase

Having your domain rules in software

http://www.sxc.hu/photo/768598

Page 42: MVC for TYPO3 4.3 with extbase

The Tower of Babel

Page 43: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - Domain Driven Design

Ubiquitous language

common vocabulary is an important prerequisite to work together

you should use the same vocabulary for discussion, modelling, development and documentation

Page 44: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - Domain Driven Design

Principles of Domain Driven Design

Domain = activity or business of user

focus on the domain

build rules of the domain in software

ubiquitous language

Page 45: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Core concepts - Domain Driven Design

Example: Phone book

showEntries()checkIfUserCanDeleteEntry()exportPhoneBook()logChanges()

Not in thePhoneBook

domain

Page 46: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Why should you use DDD?

Page 47: MVC for TYPO3 4.3 with extbase

Build complexSQL queries

Implement application logic

Mix PHP and HTML templateto build a template-based

layout

Read lots of TypoScriptand core API docs

Build frontend formswith error handling

Care about securityadapt to the coding style,structure and thinking of

different developers

Page 48: MVC for TYPO3 4.3 with extbase

http://www.sxc.hu/photo/929504

Page 49: MVC for TYPO3 4.3 with extbase

Implement application logic

Page 50: MVC for TYPO3 4.3 with extbase

http://www.sxc.hu/photo/768249

Flow [flō] is the mental state of operation in which the person is fully immersed in what he or she is doing by a feeling of energized focus, full involvement, and success in the process of the activity.

Page 51: MVC for TYPO3 4.3 with extbase
Page 52: MVC for TYPO3 4.3 with extbase
Page 53: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Abstract

The current state of the art

Core concepts - MVC and DDD

Extension building with Extbase

Outlook and conclusion

Hello world

Blog example

Persistence

Page 54: MVC for TYPO3 4.3 with extbase

How to build a typo3 v4 based app

http://www.sxc.hu/photo/516864/

Extension buildingwith Extbase

Page 55: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase

File structure

Page 56: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase

Hello World

Task: Output “Hello World”

Page 57: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase

Controller

all controllers inherit from Tx_Extbase_MVC_Controller_ActionController

Controllers contain actions: *Action

Default action: indexAction

Page 58: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Topictext

Hello World

Demo

DEMO

Page 59: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Break until 11:00

-> Start screenflow again

Page 60: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Abstract

The current state of the art

Core concepts - MVC and DDD

Extension building with Extbase

Outlook and conclusion

Hello world

Blog example

Persistence

Page 61: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Blog example

Page 62: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase

Task 1: Output a listing of blog postings

You want to output the postings of a predefined blog.

// inside the BlogController:public function showAction() { $blogUid = 1; // Fetch blog with UID 1 // pass blog to view so it can be rendered}

Page 63: MVC for TYPO3 4.3 with extbase

How would you fetch a blog?

Page 64: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Model

Page 65: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Aggregates

Post

Comment Tag

BlogRepository Aggregate RootBlog

Aggregate

Page 66: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Aggregates

Idea: Put your objects into a tree / hierarchical structure

Root of the tree: aggregate root

Aggregate roots are accessible through Repositories

Page 67: MVC for TYPO3 4.3 with extbase

Model classes are POPOs (almost)

POPO = Plain Old PHP Object

Page 68: MVC for TYPO3 4.3 with extbase

Extension building with Extbase - Blog Example

Model examples

Page 69: MVC for TYPO3 4.3 with extbase

Extension building with Extbase - Blog Example

Model examples

Page 70: MVC for TYPO3 4.3 with extbase

Extension building with Extbase - Blog Example

Model examples

Page 71: MVC for TYPO3 4.3 with extbase

Extension building with Extbase - Blog Example

Repositories

Encapsulate all data access

SQL is allowed only in the Repository

Magic methods: findBy*, findOneBy*

Page 72: MVC for TYPO3 4.3 with extbase

Extension building with Extbase - Blog Example

Repositories Blog übergeben

Page 73: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 1: Output a listing of blog postings

You want to output the postings of a predefined blog.

// inside the BlogController:public function showAction() { $blogUid = 1; $blog = $this->blogRepository->findOneByUid($blogUid); // pass blog to view so it can be rendered

}

Page 74: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 1: Output a listing of blog postings

You want to output the postings of a predefined blog.

// inside the BlogController:public function showAction() { $blogUid = 1; $blog = $this->blogRepository->findOneByUid($blogUid); $this->view->assign('blog', $blog); return $this->view->render(); // can be omitted}

Page 75: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 1: Output a listing of blog postings

Inside the template:

<h1>Welcome to {blog.name}</h1>

<f:for each="{blog.posts}" as="post"> <h1>{post.title}</h1> <f:actionlink controller="Post" action="show" arguments="{postUid : post.uid}">read more </f:actionlink></f:for>

Page 76: MVC for TYPO3 4.3 with extbase
Page 77: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 2: Display a single blog post

Display a post with comments

// inside the PostController:public function showAction() { // Get the Post UID // Fetch post with UID X // Pass post to view so it can be rendered}

Page 78: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Arguments

/** * Action that displays one single post * * @param int $postUid The uid of a post * @return string The rendered view */public function showAction($postUid) {}

Page 79: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Arguments

All arguments must be registered.

Registration of expected arguments happens through defining them as method parameters.

PHPDoc is mandatory as it is used for data type validation

Page 80: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Arguments - more advanced

/** * Action that displays one single post * * @param int $postUid The uid of a post * @return string The rendered view */public function showAction($postUid = 1) {}

Default values

Page 81: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Arguments - more advanced

/** * Action that displays one single post * * @param string $title Title of the post * @param string $content Content of the post * @validate $title Length(maximum=100) * @return string The rendered view */public function createAction($title, $content) {}

Do additional validation

Page 82: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 2: Display a single blog post

Display a post with comments

// inside the PostController:/** * @param int $postUid The post UID to be displayed */public function showAction($postUid = 0) { // Fetch post with UID X // Pass post to view so it can be rendered}

Page 83: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Aggregates - continued

Comment Tag

BlogRepository Aggregate RootBlog

Aggregate

PostRepositoryPost

Page 84: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 2: Display a single blog post

Display a post with comments

// inside the PostController:/** * @param int $postUid The post UID to be displayed */public function showAction($postUid = 0) { $post = $this->postRepository->findOneByUid($postUid); // Pass post to view so it can be rendered}

Page 85: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 2: Display a single blog post

Display a post with comments

// inside the PostController:/** * @param int $postUid The post UID to be displayed */public function showAction($postUid = 0) { $post = $this->postRepository->findOneByUid($postUid); $this->view->assign('post', $post);}

Page 86: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Topictext

Task 2: Display a single blog post - template

Page 87: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 3: Add a new comment

a new comment needs to be stored for a given post

1. Create the template

2. Add the comment in the controller

Page 88: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Extension building with Extbase - Blog Example

Task 3: Add a new comment

1. The template

Page 89: MVC for TYPO3 4.3 with extbase
Page 90: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Abstract

The current state of the art

Core concepts - MVC and DDD

Extension building with Extbase

Outlook and conclusion

Hello world

Blog example

Persistence

Page 91: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

Page 92: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

Aggregates revisited

Comment Tag

BlogRepository Aggregate RootBlog

Aggregate

PostRepositoryPost

Page 93: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

adding a blog

the blog is an aggregate root

Now, the Blog is a managed object - changes are now automatically persisted!

Persistent objectsBlogRepository

Blog$blogRepository->add(Blog $blog);

Page 94: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

adding a blog

the blog is an aggregate root

Now, the Blog is a managed object - changes are now automatically persisted!

Persistent objectsBlogRepository

Blog

$blogRepository->add(Blog $blog);

Page 95: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

PostRepository

Comment is no aggregate root

Thus, Comment is automatically persisted

Persistence

adding a comment

Persistent objects

Comment

PostPost

Page 96: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

Transparent object persistence

All objects (and their child-objects) managed by a repository are automatically persisted

changes to these objects are automatically persisted

Page 97: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Page 98: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

Summary: Domain objects

Page 99: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

Summary: Domain objects

we start with the business logic (PHP classes)

Objects represent things in the real world, with their attributes and behavior

we don't care about the database backend / persistence layer

Page 100: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Persistence

Excursus: ActiveRecord

Introduced with Ruby on Rails

Starts with the data structures in the database

attributes are not explicitly in the objects - taken from the database

class User < ActiveRecord::Base

end

Very intransparent!

Page 101: MVC for TYPO3 4.3 with extbase
Page 102: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Abstract

The current state of the art

Core concepts - MVC and DDD

Extension building with Extbase

Outlook and conclusion

Hello world

Blog example

Persistence

Page 103: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Outlook

Page 104: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Outlook

Availability and documentation

Extbase will be included in TYPO3 4.3

full-blown replacement for pibase

new preferred way to write extensions

futureproof, with concepts of FLOW3

Currently no documentation, but will be available with the final release

Page 105: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Outlook

New kickstarter

currently ongoing project by the core development team

will be released shortly after 4.3

Domain Driven Design - Don't think in databases, think in Objects!

Page 106: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Resources and links

Project web site: http://forge.typo3.org/projects/show/typo3v4-mvc

SVN: https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/

we will provide documentation until the release of TYPO3 4.3

First release with TYPO3 4.3 alpha3: http://typo3.org/download/packages/

Page 107: MVC for TYPO3 4.3 with extbase

Inspiring people toshareMVC for TYPO3 4.3 with Extbase

Conclusion

Page 108: MVC for TYPO3 4.3 with extbase

Greatly reusablecomponents

+

Page 109: MVC for TYPO3 4.3 with extbase

Easy and consistent API

+

Page 110: MVC for TYPO3 4.3 with extbase

Easily testable+

Page 111: MVC for TYPO3 4.3 with extbase

Needs initiallearning time

-

Page 112: MVC for TYPO3 4.3 with extbase

Extensionsneed proper

planning

-

Page 113: MVC for TYPO3 4.3 with extbase

You willget addicted

-

Page 114: MVC for TYPO3 4.3 with extbase

Feel the flowin TYPO3 v4

Page 115: MVC for TYPO3 4.3 with extbase

?????????????

Page 116: MVC for TYPO3 4.3 with extbase

inspiring people to share.