SlideShare ist ein Scribd-Unternehmen logo
1 von 97
Downloaden Sie, um offline zu lesen
T3DD09                       Inspiring people to
Get into FLOW with Extbase   share
Get into the FLOW with Extbase
                       15.05.2009

  Jochen Rau <jochen.rau@typoplanet.de>
 Sebastian Kurfürst <sebastian@typo3.org>
          with contributions by Oliver Hader
Topictext


Who is that?
      Dipl.-Ing. Mechanical Engineering (Stuttgart University)
      infected with TYPO3 in 2001 (after that: 5 years of immunity)
      today living and working in Tübingen
            60% self-employed TYPO3-developer (since 2007)
            60% father of a family (since 2003 ;-) )
      before that
            5 years: researcher at the Fraunhofer-Gesellschaft and the German Aerospace
            Center

                                                                        Inspiring people to
Get into FLOW with Extbase                                              share
- WARNING -
                             TYPO3 addict




                             Inspiring people to
Get into FLOW with Extbase   share
The current state
                                                                                             of the art




http://commons.wikimedia.org/wiki/File:Z%C3%BCrich_-_Seefeld_-_Heureka_IMG_1757.JPG
The current state of the art


The current state of the art
                 dispatches calls                 templates
        FE
      Plugin       fetches data                 JavaScript/CSS
                                    Resources
                  renders output                    images
           extends tslib_pibase                   TypoScript


                Database tables                      Frontend
                                                    Extension
                                                Inspiring people to
Get into FLOW with Extbase                      share
The current state of the art


File structure




                               Inspiring people to
Get into FLOW with Extbase     share
The current state of the art


A new extension: Blogging with TYPO3
      define features of the new blogging application

      implement the business logic

      define the look and feel

      take a look at security issues




                                                       Inspiring people to
Get into FLOW with Extbase                             share
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




                                                         Inspiring people to
Get into FLOW with Extbase                               share
The current state of the art




                                         Blog




                                         Post




                               Comment          Tag



                                                      Inspiring people to
Get into FLOW with Extbase                            share
The current state of the art


Blog business logic
       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);
       }

                                                         Inspiring people to
Get into FLOW with Extbase                               share
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_blogexample_blog',
       	 	 'deleted=0 AND hidden=0 AND sys_language_uid=' .
                 $GLOBALS['TSFE']->sys_language_uid .
       	 	 	 $this->cObj->enableFields('tx_blogexample_blog'),
       	 	 '',
       	 	 'name'
       	 );
          ...



                                                                 Inspiring people to
Get into FLOW with Extbase                                       share
The current state of the art


Task 1: Output a listing of blogs
      iterate through all blogs and render them
           ...
       	   $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;
       }


                                                                          Inspiring people to
Get into FLOW with Extbase                                                share
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=quot;blog elementquot;>
       	 ###BLOG_NAME###
       	 ###BLOG_LOGO###
       	 ###BLOG_DESCRIPTION###
       	 ###BLOG_MORELINK###
       </div>
       <!-- ###SUBPART_BLOGELEMENT### end -->




                                                      Inspiring people to
Get into FLOW with Extbase                            share
The current state of the art


Task 2: Display a single post with its comments
      implement a new method „renderPost()“
protected function renderPost() {
	 $post = $this->pi_getRecord('tx_blogexample_post', $this->piVars['postUid']);
	 $comments = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
	 	 '*',
	 	 'tx_blogexample_comment',
	 	 'deleted=0 AND hidden=0 AND sys_language_uid=' .
          $GLOBALS['TSFE']->sys_language_uid .
	 	 	 ' AND post_uid=' . $this->piVars['postUid'] . ' AND post_table=quot;tx_blogexample_postquot;' .
	 	 	 $this->cObj->enableFields('tx_blogexample_comment'),
	 	 '',
	 	 'date DESC'
	 );

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


                                                                      Inspiring people to
Get into FLOW with Extbase                                            share
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_blogexample_pi1|newComment = 1]
        	 plugin.tx_blogexample_pi1 = USER_INT
        [global]




                                                                   Inspiring people to
Get into FLOW with Extbase                                         share
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_blogexample_post',
       	 	 'date' => time(),
       	 	 'author' => $this->piVars['author'],
       	 	 'email' => $this->piVars['email'],
       	 	 'content' => $this->piVars['content'],
       	 );

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


                                                     Inspiring people to
Get into FLOW with Extbase                           share
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?



                                                                  Inspiring people to
Get into FLOW with Extbase                                        share
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=quot;tx_blog_postquot;' .
        $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“ ...



                                                                          Inspiring people to
Get into FLOW with Extbase                                                share
The current state of the art


Security: SQL injections - solution
      always escape or cast variables from outside
        ' AND post_uid=' . intval($this->piVars['postUid']) . ' AND post_table=quot;tx_blog_postquot;' .




                                                                          Inspiring people to
Get into FLOW with Extbase                                                share
Hmmm.
                  Much better.




                  Lasagna code
        ti code
Spaghet
Extension   Framework
Extension   Framework
http://www.sxc.hu/photo/516864/




                                                 Extension building
                                  How to build a typo3
                                  v4 based app
                                                      with Extbase
Blog




                              Post




                    Comment          Tag



                                           Inspiring people to
Get into FLOW with Extbase                 share
http://www.flickr.com/photos/bunchofpants/106465356/sizes/o/




   The model is a
representation of
          reality.
Model
class Tx_BlogExample_Domain_Model_Blog extends
Tx_Extbase_DomainObject_AbstractEntity {

	   // Comments are missing
	   protected $name = '';
	   protected $description = '';
	   protected $logo;
	   protected $posts = array();

	   public function setName($name) {
	   	 $this->name = $name;
	   }
	   public function getName() {
	   	 return $this->name;
	   }

                                                 Inspiring people to
      Get into FLOW with Extbase                 share
class Tx_BlogExample_Domain_Model_Comment extends Tx_Extbase_DomainObject_AbstractEntity {

	   protected   $date;
	   protected   $author;
	   protected   $email;
	   protected   $content;

	   public function __construct() {
	   	 $this->date = new DateTime();
	   }

	   public function setDate(DateTime $date) {
	   	 $this->date = $date;
	   }

	   public function getDate() {
	   	 return $this->date;
	   }

	   public function setAuthor($author) {                                       Inspiring people to
	     Get into FLOW with Extbase
    	 $this->author = $author;                                                 share
	   }
Model classes are POPOs (almost)
   POPO = Plain Old PHP Object
domain object encapsulates data + behavior
http://www.sxc.hu/photo/444174/




                                  and...
                                           action
Extension building with Extbase


Task 1: Output a listing of blog postings
      You want to output the postings of a predefined blog.



       public function showAction() {
         $blogUid = 1;
         // get blog by UID
         // render blog
       }




                                                             Inspiring people to
Get into FLOW with Extbase                                   share
How could you get a blog?
How could you get a book?
Extension building with Extbase - Blog Example


Model                                  BlogRepository
                                                                  Blog




                                                                  Post




                                                        Comment               Tag




                                                                  Inspiring people to
Get into FLOW with Extbase                                        share
Extension building with Extbase - Blog Example


Repositories
      Encapsulate all data access

      SQL is allowed only in the Repository

      Magic methods: findBy*, findOneBy*




                                                 Inspiring people to
Get into FLOW with Extbase                       share
Extension building with Extbase - Blog Example


  Repositories




class Tx_BlogExample_Domain_Model_BlogRepository extends Tx_Extbase_Persistence_Repository {
	
}
Extension building with Extbase - Blog Example


Task 1: Output a listing of blog postings
      You want to output the postings of a predefined blog.



       public function showAction() {
         $blogUid = 1;
         $blog = $this->blogRepository->findOneByUid($blogUid);
         // render blog
       }




                                                             Inspiring people to
Get into FLOW with Extbase                                   share
Extension building with Extbase - Blog Example


Task 1: Output a listing of blog postings
      You want to output the postings of a predefined blog.


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




                                                             Inspiring people to
Get into FLOW with Extbase                                   share
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=quot;{blog.posts}quot; as=quot;singlePostquot;>
	 	 <h1>{singlePost.title}</h1>
	 	 <f:link controller=quot;Postquot; action=quot;showquot;
                   arguments=quot;{post : singlePost}quot;>read more </f:link>
</f:for>




                                                             Inspiring people to
     Get into FLOW with Extbase                              share
Extension building with Extbase - Blog Example


Task 2: Display a single blog post
      Display a post with comments



       public function showAction() {
         // Get the post
         // Pass post to view so it can be rendered
       }




                                                      Inspiring people to
Get into FLOW with Extbase                            share
Extension building with Extbase - Blog Example


Task 2: Display a single blog post

       /**
         * Display a post
         *
         * @param Tx_Blog_Domain_Model_Post $post The post to show
         */
       public function showAction(Tx_Blog_Domain_Model_Post $post) {
           // Pass post to view so it can be rendered
       }




                                                        Inspiring people to
Get into FLOW with Extbase                              share
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




                                                                   Inspiring people to
Get into FLOW with Extbase                                         share
Extension building with Extbase - Blog Example


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




                                                      Inspiring people to
Get into FLOW with Extbase                            share
Extension building with Extbase - Blog Example


Task 2: Display a single blog post

       /**
         * Display a post
         *
         * @param Tx_Blog_Domain_Model_Post $post The post to show
         */
       public function showAction(Tx_Blog_Domain_Model_Post $post) {
           $this->view->assign('post', $post);
       }




                                                        Inspiring people to
Get into FLOW with Extbase                              share
Extension building with Extbase - Blog Example


Task 2: Display a single blog post - template




                                                 Inspiring people to
Get into FLOW with Extbase                       share
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




                                                          Inspiring people to
Get into FLOW with Extbase                                share
<f:form name=quot;commentquot; method=quot;postquot; controllerName=quot;Commentquot; actionName=quot;createquot; object=quot;{comment}quot;
arguments=quot;{post : post}quot;>
	 <h4>Add your own</h4>
	 <label for=quot;authorquot;>name <span class=quot;requiredquot;>(required)</span></label><br />
	 <f:form.textbox id=quot;authorquot; property=quot;authorquot; />
	 <br />
	 <label for=quot;emailquot;>email <span class=quot;requiredquot;>(required)</span></label><br />
	 <f:form.textbox id=quot;emailquot; property=quot;emailquot; />
	 <br />
	 <label for=quot;textquot;>message <span class=quot;requiredquot;>(required)</span></label><br />
	 <f:form.textarea id=quot;textquot; property=quot;contentquot; rows=quot;8quot; cols=quot;46quot;/>
	 <br />
	 <f:form.submit>Say it</f:form.submit>
</f:form>




                                                                             Inspiring people to
   Get into FLOW with Extbase                                                share
<f:form name=quot;commentquot; method=quot;postquot; controllerName=quot;Commentquot; actionName=quot;createquot; object=quot;{comment}quot;
   arguments=quot;{post : post}quot;>
   	




/**
  * Action that adds a comment to a blog post and redirects to single view
  *
  * @param Tx_BlogExample_Domain_Model_Post $post The post the comment is related to
  * @param Tx_BlogExample_Domain_Model_Comment $comment The comment to create
  * @return void
  */
public function createAction(Tx_BlogExample_Domain_Model_Post $post, Tx_BlogExample_Domain_Model_Comment $comment) {
	 $post->addComment($comment);
	 $this->redirect('show', 'Post', NULL, array('post' => $post));
}



                                                                                    Inspiring people to
          Get into FLOW with Extbase                                                share
1
                                      2
        userFunc
                                   Request
                                                        BlogExample
                    Extbase
TYPO3              Dispatcher
         HTML
                                Response        Controller
          6
                           3                                    assign(Blog)

                         findByName('MyBlog')                       render()     5
                                                 Blog
                                                         Response
                                                   4                      View
                           Repository


                                                Domain Model
                                   Blog


                                   Post



                           Comment         Tag
Extension building with Extbase


Controller
      Controllers contain actions: *Action

      all controllers inherit from Tx_Extbase_MVC_Controller_ActionController

      Default action: indexAction




                                                                    Inspiring people to
Get into FLOW with Extbase                                          share
Controlle
                r



      Model




          View




Oth
   er
        Stu
           ff
Persistence




                                       Inspiring people to
Get into FLOW with Extbase             share
Aggregate
getLatestComment()                            Root
                               Blog




                               Post




                     Comment          Tag
Persistence


 adding a blog
        the blog is an aggregate root
                                                                                      Persistent objects
                                                             BlogRepository
                    $blogRepository->add(Blog $blog);

Blog




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


                                                                          Inspiring people to
 Get into FLOW with Extbase                                               share
Persistence


  adding a comment
         Comment is no aggregate root
                                                                             Persistent objects
         Thus, Comment is automatically persisted   PostRepository




                                                         Post



Comment


                                                                 Inspiring people to
  Get into FLOW with Extbase                                     share
Persistence


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

      changes to these objects are automatically persisted




                                                                       Inspiring people to
Get into FLOW with Extbase                                             share
Inspiring people to
Get into FLOW with Extbase   share
Domain Driven Design
Domain describes activity or
    business of user.
Ubiquitous LAnguage
Blog


Entity

                   Post


                                Value
                                Object
         Comment          Tag
Core concepts - Domain Driven Design


Principles of Domain Driven Design
      focus on the domain = activity or business of user
         we start with the business logic (PHP classes)
         we don't care about the database backend / persistence layer
      bbjects represent things in the real world, with their attributes and behavior
      ubiquitous language
      building blocks
         Entity
         Value Objects
         Repositories

                                                                        Inspiring people to
Get into FLOW with Extbase                                              share
Why should you use DDD?




                                         Inspiring people to
Get into FLOW with Extbase               share
Read lots of TypoScript
  and core API docs                Mix PHP and HTML template
                                   to build a template-based
                                             layout
    Build frontend forms
     with error handling

                          Implement application logic
     Care about security
                                              adapt to the coding style,
                        Build complex         structure and thinking of
                         SQL queries             different developers
http://www.sxc.hu/photo/929504
Implement application logic
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.




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




                                       Inspiring people to
Get into FLOW with Extbase             share
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




                                                                      Inspiring people to
Get into FLOW with Extbase                                            share
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!




                                                                      Inspiring people to
Get into FLOW with Extbase                                            share
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/




                                                                   Inspiring people to
Get into FLOW with Extbase                                         share
Conclusion




                                      Inspiring people to
Get into FLOW with Extbase            share
+
    Greatly reusable
      components
+
      Easy and
    consistent API
+   Easily testable
-


Needs initial
learning time
-    Extensions
    need proper
       planning
-

      You will
    get addicted
Feel the flow
 in TYPO3 v4
Bastian Waidelich
                                                       Niels Pardon




                                   u
                         Tha nk Yo


                   and the TYPO3 V5 Team for all the
                  inspiration and the beautiful code      Christopher Hlubek




Ingmar Schlecht


                                    Benjamin Mack
??????
    ???
 ???
 ?
inspiring people to share.

Weitere ähnliche Inhalte

Andere mochten auch

Embracing Collaborative Design
Embracing Collaborative DesignEmbracing Collaborative Design
Embracing Collaborative DesignUXconference
 
Situaciones deseadas y no deseadas
Situaciones deseadas y no deseadasSituaciones deseadas y no deseadas
Situaciones deseadas y no deseadasEmerson Salcedo
 
Wifi sip ip phone sc 6600 catalog march 22
Wifi sip ip phone sc 6600 catalog march 22Wifi sip ip phone sc 6600 catalog march 22
Wifi sip ip phone sc 6600 catalog march 22solomonmin
 
Solucions Topcon per a l'auscultació automàtica amb estacions totals de precisió
Solucions Topcon per a l'auscultació automàtica amb estacions totals de precisióSolucions Topcon per a l'auscultació automàtica amb estacions totals de precisió
Solucions Topcon per a l'auscultació automàtica amb estacions totals de precisióInstitut Cartogràfic de Catalunya
 
Relevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USA
Relevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USARelevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USA
Relevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USALeonardo Dias
 
Fort Meade SoundOff for July 12, 2012
Fort Meade SoundOff for July 12, 2012Fort Meade SoundOff for July 12, 2012
Fort Meade SoundOff for July 12, 2012ftmeade
 
Part 1 strategic human resources
Part 1   strategic human resourcesPart 1   strategic human resources
Part 1 strategic human resourcessudarsono mr
 
Regulatory Information Management
Regulatory Information ManagementRegulatory Information Management
Regulatory Information ManagementJBScott44
 
Edu,jharvey,biel i marc sala experiments
Edu,jharvey,biel i marc sala experimentsEdu,jharvey,biel i marc sala experiments
Edu,jharvey,biel i marc sala experiments6primariaparecollvic
 
Presentación de Internet TV (IPTV)
Presentación de Internet TV (IPTV)Presentación de Internet TV (IPTV)
Presentación de Internet TV (IPTV)trademarketingHE
 
Lean six sigma training and certification from TUV SUD ( Globally recognized)
Lean six sigma training and certification from TUV SUD ( Globally recognized)Lean six sigma training and certification from TUV SUD ( Globally recognized)
Lean six sigma training and certification from TUV SUD ( Globally recognized)PriSkills Knowledge Solutions
 
La práctica del atletismo en personas con discapacidad (1) Cristian Zamora
La práctica del atletismo en personas con discapacidad (1) Cristian ZamoraLa práctica del atletismo en personas con discapacidad (1) Cristian Zamora
La práctica del atletismo en personas con discapacidad (1) Cristian Zamoracristiansamisan
 
Trignometria 5º primera parte
Trignometria 5º   primera parteTrignometria 5º   primera parte
Trignometria 5º primera partecjperu
 

Andere mochten auch (17)

Embracing Collaborative Design
Embracing Collaborative DesignEmbracing Collaborative Design
Embracing Collaborative Design
 
Situaciones deseadas y no deseadas
Situaciones deseadas y no deseadasSituaciones deseadas y no deseadas
Situaciones deseadas y no deseadas
 
ReuniÓn De Padres
ReuniÓn De PadresReuniÓn De Padres
ReuniÓn De Padres
 
Wifi sip ip phone sc 6600 catalog march 22
Wifi sip ip phone sc 6600 catalog march 22Wifi sip ip phone sc 6600 catalog march 22
Wifi sip ip phone sc 6600 catalog march 22
 
Solucions Topcon per a l'auscultació automàtica amb estacions totals de precisió
Solucions Topcon per a l'auscultació automàtica amb estacions totals de precisióSolucions Topcon per a l'auscultació automàtica amb estacions totals de precisió
Solucions Topcon per a l'auscultació automàtica amb estacions totals de precisió
 
Relevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USA
Relevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USARelevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USA
Relevancy and synonyms - ApacheCon NA 2013 - Portland, Oregon, USA
 
Fort Meade SoundOff for July 12, 2012
Fort Meade SoundOff for July 12, 2012Fort Meade SoundOff for July 12, 2012
Fort Meade SoundOff for July 12, 2012
 
Part 1 strategic human resources
Part 1   strategic human resourcesPart 1   strategic human resources
Part 1 strategic human resources
 
Blusens Networks IPTV 2013
Blusens Networks IPTV 2013Blusens Networks IPTV 2013
Blusens Networks IPTV 2013
 
Regulatory Information Management
Regulatory Information ManagementRegulatory Information Management
Regulatory Information Management
 
Edu,jharvey,biel i marc sala experiments
Edu,jharvey,biel i marc sala experimentsEdu,jharvey,biel i marc sala experiments
Edu,jharvey,biel i marc sala experiments
 
Presentación de Internet TV (IPTV)
Presentación de Internet TV (IPTV)Presentación de Internet TV (IPTV)
Presentación de Internet TV (IPTV)
 
Lean six sigma training and certification from TUV SUD ( Globally recognized)
Lean six sigma training and certification from TUV SUD ( Globally recognized)Lean six sigma training and certification from TUV SUD ( Globally recognized)
Lean six sigma training and certification from TUV SUD ( Globally recognized)
 
GUILLERMO SIMÓN.
GUILLERMO SIMÓN.GUILLERMO SIMÓN.
GUILLERMO SIMÓN.
 
La práctica del atletismo en personas con discapacidad (1) Cristian Zamora
La práctica del atletismo en personas con discapacidad (1) Cristian ZamoraLa práctica del atletismo en personas con discapacidad (1) Cristian Zamora
La práctica del atletismo en personas con discapacidad (1) Cristian Zamora
 
Cortes hermanos
Cortes hermanosCortes hermanos
Cortes hermanos
 
Trignometria 5º primera parte
Trignometria 5º   primera parteTrignometria 5º   primera parte
Trignometria 5º primera parte
 

Mehr von Sebastian Kurfürst

The Current State of TYPO3 Phoenix -- T3CON11
The Current State of TYPO3 Phoenix -- T3CON11The Current State of TYPO3 Phoenix -- T3CON11
The Current State of TYPO3 Phoenix -- T3CON11Sebastian Kurfürst
 
Workshop Extension-Entwicklung mit Extbase und Fluid
Workshop Extension-Entwicklung mit Extbase und FluidWorkshop Extension-Entwicklung mit Extbase und Fluid
Workshop Extension-Entwicklung mit Extbase und FluidSebastian Kurfürst
 
Fluid - Templating for professionals - T3CON09
Fluid - Templating for professionals - T3CON09Fluid - Templating for professionals - T3CON09
Fluid - Templating for professionals - T3CON09Sebastian Kurfürst
 
FLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
FLOW3 - der aktuelle Stand. TYPO3 Usergroup DresdenFLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
FLOW3 - der aktuelle Stand. TYPO3 Usergroup DresdenSebastian Kurfürst
 
Continuous Integration at T3CON08
Continuous Integration at T3CON08Continuous Integration at T3CON08
Continuous Integration at T3CON08Sebastian Kurfürst
 

Mehr von Sebastian Kurfürst (11)

The Current State of TYPO3 Phoenix -- T3CON11
The Current State of TYPO3 Phoenix -- T3CON11The Current State of TYPO3 Phoenix -- T3CON11
The Current State of TYPO3 Phoenix -- T3CON11
 
FLOW3 Goes Semantic
FLOW3 Goes SemanticFLOW3 Goes Semantic
FLOW3 Goes Semantic
 
Advanced Fluid
Advanced FluidAdvanced Fluid
Advanced Fluid
 
Fluid for Designers
Fluid for DesignersFluid for Designers
Fluid for Designers
 
Workshop Extension-Entwicklung mit Extbase und Fluid
Workshop Extension-Entwicklung mit Extbase und FluidWorkshop Extension-Entwicklung mit Extbase und Fluid
Workshop Extension-Entwicklung mit Extbase und Fluid
 
Schulung Fluid Templating
Schulung Fluid TemplatingSchulung Fluid Templating
Schulung Fluid Templating
 
Fluid - Templating for professionals - T3CON09
Fluid - Templating for professionals - T3CON09Fluid - Templating for professionals - T3CON09
Fluid - Templating for professionals - T3CON09
 
Fluid - The Zen of Templating
Fluid - The Zen of TemplatingFluid - The Zen of Templating
Fluid - The Zen of Templating
 
MVC for TYPO3 4.3 with extbase
MVC for TYPO3 4.3 with extbaseMVC for TYPO3 4.3 with extbase
MVC for TYPO3 4.3 with extbase
 
FLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
FLOW3 - der aktuelle Stand. TYPO3 Usergroup DresdenFLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
FLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
 
Continuous Integration at T3CON08
Continuous Integration at T3CON08Continuous Integration at T3CON08
Continuous Integration at T3CON08
 

Kürzlich hochgeladen

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Kürzlich hochgeladen (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

Get into the FLOW with Extbase and TYPO3 4.3

  • 1. T3DD09 Inspiring people to Get into FLOW with Extbase share
  • 2. Get into the FLOW with Extbase 15.05.2009 Jochen Rau <jochen.rau@typoplanet.de> Sebastian Kurfürst <sebastian@typo3.org> with contributions by Oliver Hader
  • 3. Topictext Who is that? Dipl.-Ing. Mechanical Engineering (Stuttgart University) infected with TYPO3 in 2001 (after that: 5 years of immunity) today living and working in Tübingen 60% self-employed TYPO3-developer (since 2007) 60% father of a family (since 2003 ;-) ) before that 5 years: researcher at the Fraunhofer-Gesellschaft and the German Aerospace Center Inspiring people to Get into FLOW with Extbase share
  • 4. - WARNING - TYPO3 addict Inspiring people to Get into FLOW with Extbase share
  • 5. The current state of the art http://commons.wikimedia.org/wiki/File:Z%C3%BCrich_-_Seefeld_-_Heureka_IMG_1757.JPG
  • 6. The current state of the art The current state of the art dispatches calls templates FE Plugin fetches data JavaScript/CSS Resources renders output images extends tslib_pibase TypoScript Database tables Frontend Extension Inspiring people to Get into FLOW with Extbase share
  • 7. The current state of the art File structure Inspiring people to Get into FLOW with Extbase share
  • 8. The current state of the art A new extension: Blogging with TYPO3 define features of the new blogging application implement the business logic define the look and feel take a look at security issues Inspiring people to Get into FLOW with Extbase share
  • 9. 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 Inspiring people to Get into FLOW with Extbase share
  • 10. The current state of the art Blog Post Comment Tag Inspiring people to Get into FLOW with Extbase share
  • 11. The current state of the art Blog business logic 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); } Inspiring people to Get into FLOW with Extbase share
  • 12. 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_blogexample_blog', 'deleted=0 AND hidden=0 AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid . $this->cObj->enableFields('tx_blogexample_blog'), '', 'name' ); ... Inspiring people to Get into FLOW with Extbase share
  • 13. The current state of the art Task 1: Output a listing of blogs iterate through all blogs and render them ... $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; } Inspiring people to Get into FLOW with Extbase share
  • 14. 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=quot;blog elementquot;> ###BLOG_NAME### ###BLOG_LOGO### ###BLOG_DESCRIPTION### ###BLOG_MORELINK### </div> <!-- ###SUBPART_BLOGELEMENT### end --> Inspiring people to Get into FLOW with Extbase share
  • 15.
  • 16. The current state of the art Task 2: Display a single post with its comments implement a new method „renderPost()“ protected function renderPost() { $post = $this->pi_getRecord('tx_blogexample_post', $this->piVars['postUid']); $comments = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( '*', 'tx_blogexample_comment', 'deleted=0 AND hidden=0 AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid . ' AND post_uid=' . $this->piVars['postUid'] . ' AND post_table=quot;tx_blogexample_postquot;' . $this->cObj->enableFields('tx_blogexample_comment'), '', 'date DESC' ); // fill marker arrays and substitute in template // return content } Inspiring people to Get into FLOW with Extbase share
  • 17. 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_blogexample_pi1|newComment = 1] plugin.tx_blogexample_pi1 = USER_INT [global] Inspiring people to Get into FLOW with Extbase share
  • 18. 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_blogexample_post', 'date' => time(), 'author' => $this->piVars['author'], 'email' => $this->piVars['email'], 'content' => $this->piVars['content'], ); $GLOBALS['TYPO3_DB']->exec_INSERTquery( 'tx_blogexample_comment', $fields ); } Inspiring people to Get into FLOW with Extbase share
  • 19. 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? Inspiring people to Get into FLOW with Extbase share
  • 20. 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=quot;tx_blog_postquot;' . $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“ ... Inspiring people to Get into FLOW with Extbase share
  • 21. The current state of the art Security: SQL injections - solution always escape or cast variables from outside ' AND post_uid=' . intval($this->piVars['postUid']) . ' AND post_table=quot;tx_blog_postquot;' . Inspiring people to Get into FLOW with Extbase share
  • 22.
  • 23. Hmmm. Much better. Lasagna code ti code Spaghet
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. Extension Framework
  • 31. Extension Framework
  • 32.
  • 33. http://www.sxc.hu/photo/516864/ Extension building How to build a typo3 v4 based app with Extbase
  • 34. Blog Post Comment Tag Inspiring people to Get into FLOW with Extbase share
  • 35. http://www.flickr.com/photos/bunchofpants/106465356/sizes/o/ The model is a representation of reality.
  • 36. Model
  • 37. class Tx_BlogExample_Domain_Model_Blog extends Tx_Extbase_DomainObject_AbstractEntity { // Comments are missing protected $name = ''; protected $description = ''; protected $logo; protected $posts = array(); public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } Inspiring people to Get into FLOW with Extbase share
  • 38. class Tx_BlogExample_Domain_Model_Comment extends Tx_Extbase_DomainObject_AbstractEntity { protected $date; protected $author; protected $email; protected $content; public function __construct() { $this->date = new DateTime(); } public function setDate(DateTime $date) { $this->date = $date; } public function getDate() { return $this->date; } public function setAuthor($author) { Inspiring people to Get into FLOW with Extbase $this->author = $author; share }
  • 39. Model classes are POPOs (almost) POPO = Plain Old PHP Object
  • 40. domain object encapsulates data + behavior
  • 41.
  • 43. Extension building with Extbase Task 1: Output a listing of blog postings You want to output the postings of a predefined blog. public function showAction() { $blogUid = 1; // get blog by UID // render blog } Inspiring people to Get into FLOW with Extbase share
  • 44. How could you get a blog?
  • 45. How could you get a book?
  • 46. Extension building with Extbase - Blog Example Model BlogRepository Blog Post Comment Tag Inspiring people to Get into FLOW with Extbase share
  • 47. Extension building with Extbase - Blog Example Repositories Encapsulate all data access SQL is allowed only in the Repository Magic methods: findBy*, findOneBy* Inspiring people to Get into FLOW with Extbase share
  • 48. Extension building with Extbase - Blog Example Repositories class Tx_BlogExample_Domain_Model_BlogRepository extends Tx_Extbase_Persistence_Repository { }
  • 49. Extension building with Extbase - Blog Example Task 1: Output a listing of blog postings You want to output the postings of a predefined blog. public function showAction() { $blogUid = 1; $blog = $this->blogRepository->findOneByUid($blogUid); // render blog } Inspiring people to Get into FLOW with Extbase share
  • 50. Extension building with Extbase - Blog Example Task 1: Output a listing of blog postings You want to output the postings of a predefined blog. public function showAction() { $blogUid = 1; $blog = $this->blogRepository->findOneByUid($blogUid); $this->view->assign('blog', $blog); return $this->view->render(); // can be omitted } Inspiring people to Get into FLOW with Extbase share
  • 51. 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=quot;{blog.posts}quot; as=quot;singlePostquot;> <h1>{singlePost.title}</h1> <f:link controller=quot;Postquot; action=quot;showquot; arguments=quot;{post : singlePost}quot;>read more </f:link> </f:for> Inspiring people to Get into FLOW with Extbase share
  • 52.
  • 53. Extension building with Extbase - Blog Example Task 2: Display a single blog post Display a post with comments public function showAction() { // Get the post // Pass post to view so it can be rendered } Inspiring people to Get into FLOW with Extbase share
  • 54. Extension building with Extbase - Blog Example Task 2: Display a single blog post /** * Display a post * * @param Tx_Blog_Domain_Model_Post $post The post to show */ public function showAction(Tx_Blog_Domain_Model_Post $post) { // Pass post to view so it can be rendered } Inspiring people to Get into FLOW with Extbase share
  • 55. 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 Inspiring people to Get into FLOW with Extbase share
  • 56. Extension building with Extbase - Blog Example Arguments - more advanced /** * Action that displays one single post Do * * @param string $title Title of the post additional validation * @param string $content Content of the post * @validate $title Length(maximum=100) * @return string The rendered view */ public function createAction($title, $content) { } Inspiring people to Get into FLOW with Extbase share
  • 57. Extension building with Extbase - Blog Example Task 2: Display a single blog post /** * Display a post * * @param Tx_Blog_Domain_Model_Post $post The post to show */ public function showAction(Tx_Blog_Domain_Model_Post $post) { $this->view->assign('post', $post); } Inspiring people to Get into FLOW with Extbase share
  • 58. Extension building with Extbase - Blog Example Task 2: Display a single blog post - template Inspiring people to Get into FLOW with Extbase share
  • 59. 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 Inspiring people to Get into FLOW with Extbase share
  • 60. <f:form name=quot;commentquot; method=quot;postquot; controllerName=quot;Commentquot; actionName=quot;createquot; object=quot;{comment}quot; arguments=quot;{post : post}quot;> <h4>Add your own</h4> <label for=quot;authorquot;>name <span class=quot;requiredquot;>(required)</span></label><br /> <f:form.textbox id=quot;authorquot; property=quot;authorquot; /> <br /> <label for=quot;emailquot;>email <span class=quot;requiredquot;>(required)</span></label><br /> <f:form.textbox id=quot;emailquot; property=quot;emailquot; /> <br /> <label for=quot;textquot;>message <span class=quot;requiredquot;>(required)</span></label><br /> <f:form.textarea id=quot;textquot; property=quot;contentquot; rows=quot;8quot; cols=quot;46quot;/> <br /> <f:form.submit>Say it</f:form.submit> </f:form> Inspiring people to Get into FLOW with Extbase share
  • 61. <f:form name=quot;commentquot; method=quot;postquot; controllerName=quot;Commentquot; actionName=quot;createquot; object=quot;{comment}quot; arguments=quot;{post : post}quot;> /** * Action that adds a comment to a blog post and redirects to single view * * @param Tx_BlogExample_Domain_Model_Post $post The post the comment is related to * @param Tx_BlogExample_Domain_Model_Comment $comment The comment to create * @return void */ public function createAction(Tx_BlogExample_Domain_Model_Post $post, Tx_BlogExample_Domain_Model_Comment $comment) { $post->addComment($comment); $this->redirect('show', 'Post', NULL, array('post' => $post)); } Inspiring people to Get into FLOW with Extbase share
  • 62. 1 2 userFunc Request BlogExample Extbase TYPO3 Dispatcher HTML Response Controller 6 3 assign(Blog) findByName('MyBlog') render() 5 Blog Response 4 View Repository Domain Model Blog Post Comment Tag
  • 63. Extension building with Extbase Controller Controllers contain actions: *Action all controllers inherit from Tx_Extbase_MVC_Controller_ActionController Default action: indexAction Inspiring people to Get into FLOW with Extbase share
  • 64. Controlle r Model View Oth er Stu ff
  • 65. Persistence Inspiring people to Get into FLOW with Extbase share
  • 66. Aggregate getLatestComment() Root Blog Post Comment Tag
  • 67. Persistence adding a blog the blog is an aggregate root Persistent objects BlogRepository $blogRepository->add(Blog $blog); Blog Now, the Blog is a managed object - changes are now automatically persisted! Inspiring people to Get into FLOW with Extbase share
  • 68. Persistence adding a comment Comment is no aggregate root Persistent objects Thus, Comment is automatically persisted PostRepository Post Comment Inspiring people to Get into FLOW with Extbase share
  • 69. Persistence Transparent object persistence All objects (and their child-objects) managed by a repository are automatically persisted changes to these objects are automatically persisted Inspiring people to Get into FLOW with Extbase share
  • 70. Inspiring people to Get into FLOW with Extbase share
  • 72. Domain describes activity or business of user.
  • 74. Blog Entity Post Value Object Comment Tag
  • 75. Core concepts - Domain Driven Design Principles of Domain Driven Design focus on the domain = activity or business of user we start with the business logic (PHP classes) we don't care about the database backend / persistence layer bbjects represent things in the real world, with their attributes and behavior ubiquitous language building blocks Entity Value Objects Repositories Inspiring people to Get into FLOW with Extbase share
  • 76. Why should you use DDD? Inspiring people to Get into FLOW with Extbase share
  • 77. Read lots of TypoScript and core API docs Mix PHP and HTML template to build a template-based layout Build frontend forms with error handling Implement application logic Care about security adapt to the coding style, Build complex structure and thinking of SQL queries different developers
  • 80. 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. http://www.sxc.hu/photo/768249
  • 81.
  • 82.
  • 83. Outlook Inspiring people to Get into FLOW with Extbase share
  • 84. 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 Inspiring people to Get into FLOW with Extbase share
  • 85. 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! Inspiring people to Get into FLOW with Extbase share
  • 86. 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/ Inspiring people to Get into FLOW with Extbase share
  • 87. Conclusion Inspiring people to Get into FLOW with Extbase share
  • 88. + Greatly reusable components
  • 89. + Easy and consistent API
  • 90. + Easily testable
  • 92. - Extensions need proper planning
  • 93. - You will get addicted
  • 94. Feel the flow in TYPO3 v4
  • 95. Bastian Waidelich Niels Pardon u Tha nk Yo and the TYPO3 V5 Team for all the inspiration and the beautiful code Christopher Hlubek Ingmar Schlecht Benjamin Mack
  • 96. ?????? ??? ??? ?