t3con14eu: migrating from typo3 cms to typo3 flow

33
Migrating from TYPO3 CMS to TYPO3 Flow 10th International TYPO3 Conference, October 9th, Berlin CC BY Serge Melki https://www.ickr.com/photos/sergemelki/8156340258 Martin Helmich [email protected]

Upload: mhelmich

Post on 27-Jun-2015

356 views

Category:

Software


2 download

DESCRIPTION

Slides of my presentation held at the 10th International TYPO3 Conference in Berlin on October 9th, 2014.

TRANSCRIPT

Page 1: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

Migrating from TYPO3 CMS to TYPO3 Flow 10th International TYPO3 Conference, October 9th, Berlin

CC BY Serge Melki https://www.flickr.com/photos/sergemelki/8156340258

Martin Helmich [email protected]

Page 2: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
Page 3: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
Page 4: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

CC BY-SA Niteshift http://commons.wikimedia.org/wiki/File:Balow_Kuhweide_2008-04-28_121.jpg

Page 5: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 Flow

TYPO3 Neos

?

TYPO3 CMS

Page 6: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

why!?

CC BY Morgan https://www.flickr.com/photos/meddygarnet/3528509573

Page 7: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

CC BY Crisada https://www.flickr.com/photos/chrisada/2415541623

Page 8: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

CC BY Pascal https://www.flickr.com/photos/pasukaru76/6310053615

Page 9: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

CC BY-SA Malene Thyssen http://commons.wikimedia.org/wiki/File:Brown_bear_(Ursus_arctos_arctos)_running.jpg

Page 10: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

CC BY Emma Bishop https://www.flickr.com/photos/emmabishop/6360703145

Page 11: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

Extensions

Typoscript

Content

Page 12: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

Migrating content

Read https://speakerdeck.com/kdambekalns/migrating-from-typo3-cms-to-typo3-neos

Page 13: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

Migrating typoscript

just

don‘t

Page 14: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

although...

page  =  PAGE  page  {        10  =  TEMPLATE      10  {          template  =  FILE          template.file  =  fileadmin/site.html            marks  {              CONTENT  <  styles.content.get              CONTENT_RIGHT  <  styles.content.getRight          }      }    }  

page  =  TYPO3.Neos:Page  {      body  {          templatePath  =  

'resource://My.Site/.../Site.html'            content  {              main  =  PrimaryContent  {                  nodePath  =  'main'              }              right  =  ContentCollection  {                  nodePath  =  'right'              }          }            

Page 15: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

Render TS2

Parse TS

Apply trans-

formations

Page 16: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

How to convert an

Extbase extension to TYPO3 FLOW

Page 17: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 CMS (Extbase)

TYPO3 Flow

?

Classes/ Controller/ Domain/ …

Configuration/ TypoScript/ TCA/

Resources/ Public/ Private/

ext_emconf.php ext_tables.php ext_tables.sql

Classes/ Controller/ Domain/ …

Configuration/ Migrations/

Mysql/ Resources/

Public/ Private/

composer.json

Page 18: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 CMS (Extbase)

TYPO3 Flow

class  Tx_MyExt_Domain_Model_Car  extends        Tx_Extbase_DomainObject_AbstractEntity  {        /**        *  @var  string        *  @validate  notempty        */      protected  $licenseNumber;        /**        *  @var  Tx_MyExt_Domain_Model_Manufacturer        */      protected  $manufacturer;  }  

namespace  My\Ext\Domain\Model;  use  TYPO3\Flow\Annotations  as  Flow;  use  Doctrine\ORM\Mapping  as  ORM;    /**    *  @Flow\Entity    */  class  Car  {        /**        *  @var  string        *  @Flow\Validate('NotEmpty')        */      protected  $licenseNumber;        /**        *  @var  Manufacturer        *  @ORM\ManyToOne        */      protected  $manufacturer;  }  

Page 19: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 CMS (Extbase)

TYPO3 Flow

class  Tx_MyExt_Domain_Model_Car  extends        Tx_Extbase_DomainObject_AbstractEntity  {        /**        *  @var  string        *  @validate  notempty        */      protected  $licenseNumber;        /**        *  @var  Tx_MyExt_Domain_Model_Manufacturer        */      protected  $manufacturer;  }  

namespace  My\Ext\Domain\Model;  use  TYPO3\Flow\Annotations  as  Flow;  use  Doctrine\ORM\Mapping  as  ORM;    /**    *  @Flow\Entity    */  class  Car  {        /**        *  @var  string        *  @Flow\Validate('NotEmpty')        */      protected  $licenseNumber;        /**        *  @var  Manufacturer        *  @ORM\ManyToOne        */      protected  $manufacturer;  }  

Namespacify classes when necessary

Page 20: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 CMS (Extbase)

TYPO3 Flow

class  Tx_MyExt_Domain_Model_Car  extends        Tx_Extbase_DomainObject_AbstractEntity  {        /**        *  @var  string        *  @validate  notempty        */      protected  $licenseNumber;        /**        *  @var  Tx_MyExt_Domain_Model_Manufacturer        */      protected  $manufacturer;  }  

namespace  My\Ext\Domain\Model;  use  TYPO3\Flow\Annotations  as  Flow;  use  Doctrine\ORM\Mapping  as  ORM;    /**    *  @Flow\Entity    */  class  Car  {        /**        *  @var  string        *  @Flow\Validate('NotEmpty')        */      protected  $licenseNumber;        /**        *  @var  Manufacturer        *  @ORM\ManyToOne        */      protected  $manufacturer;  }  

Determine domain object type by class inheritance and add annotation

Page 21: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 CMS (Extbase)

TYPO3 Flow

class  Tx_MyExt_Domain_Model_Car  extends        Tx_Extbase_DomainObject_AbstractEntity  {        /**        *  @var  string        *  @validate  notempty        */      protected  $licenseNumber;        /**        *  @var  Tx_MyExt_Domain_Model_Manufacturer        */      protected  $manufacturer;  }  

namespace  My\Ext\Domain\Model;  use  TYPO3\Flow\Annotations  as  Flow;  use  Doctrine\ORM\Mapping  as  ORM;    /**    *  @Flow\Entity    */  class  Car  {        /**        *  @var  string        *  @Flow\Validate('NotEmpty')        */      protected  $licenseNumber;        /**        *  @var  Manufacturer        *  @ORM\ManyToOne        */      protected  $manufacturer;  }  

Convert annotations.

Page 22: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 CMS (Extbase)

TYPO3 Flow

class  Tx_MyExt_Domain_Model_Car  extends        Tx_Extbase_DomainObject_AbstractEntity  {        /**        *  @var  string        *  @validate  notempty        */      protected  $licenseNumber;        /**        *  @var  Tx_MyExt_Domain_Model_Manufacturer        */      protected  $manufacturer;  }  

namespace  My\Ext\Domain\Model;  use  TYPO3\Flow\Annotations  as  Flow;  use  Doctrine\ORM\Mapping  as  ORM;    /**    *  @Flow\Entity    */  class  Car  {        /**        *  @var  string        *  @Flow\Validate('NotEmpty')        */      protected  $licenseNumber;        /**        *  @var  Manufacturer        *  @ORM\ManyToOne        */      protected  $manufacturer;  }  

Determine association cardinality from TCA

Page 23: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

some other

stuff to think about

usage of TYPO3 APIs (aka. the infamous t3lib_div)

Conv

ert l

ocal

lang

to

XLI

FF create doctrine

migrations from ext_tables.sql do

mai

n m

odel

s ex

tend

ing

TYPO

3 cl

asse

s different value object

handling

Page 24: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

How to convert an

pibase extension to TYPO3 FLOW

Page 25: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

TYPO3 CMS (pibase)

TYPO3 Flow

lib/ pi1/

class.tx_myext_pi1.php static/

res/ ext_emconf.php ext_tables.php ext_tables.sql

Classes/ Controller/ Domain/ Plugin/ …

Configuration/ Migrations/

Mysql/ Resources/

Public/ Private/

composer.json

?

Page 26: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

class  tx_myext_pi1  extends  tslib_pibase  {      public  function  main($conf,  $content)  {          $mainTemplate  =  $this-­‐>cObj-­‐>fileResource(...);          $rowTemplate    =  $this-­‐>cObj-­‐>fileResource(...);          $userRes  =  $GLOBALS['TYPO3_DB']-­‐>exec_SELECTquery(              '*',  'tx_myext_users',  'deleted=0  AND  active=1'          );          while($user  =  $GLOBALS['TYPO3_DB']-­‐>sql_fetch_assoc($userRes))  {              $markers  =  [                  "###NAME###"    =>  $user['name'],                  "###EMAIL###"  =>  $user['email']              ];              $content  .=  $this-­‐>cObj-­‐>substituteMarkerArray(                  $rowTemplate,  $markers              );          }            $markers  =  ['###USERS###'  =>  $content];          return  $this-­‐>cObj-­‐>substituteMarkerArray($mainTemplate,  $markers);      }  }  

Page 27: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

Doctrine 2 DBAL

Doctrine 2 ORM Flow

Resource Mgmt.

Flow MVC Stack

Pain abstraction layer

The world of pain (old code)

Page 28: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

namespace  My\Ext\Plugin;  class  UserListPlugin  extends  \Mw\T3Compat\Plugin\BasePlugin  {      public  function  main($conf,  $content)  {          $mainTemplate  =  $this-­‐>cObj-­‐>fileResource(...);          $rowTemplate    =  $this-­‐>cObj-­‐>fileResource(...);          $userRes  =  $this-­‐>database-­‐>exec_SELECTquery(              '*',  'tx_myext_users',  'deleted=0  AND  active=1'          );          while($user  =  $this-­‐>database-­‐>sql_fetch_assoc($userRes))  {              $markers  =  [                  "###NAME###"    =>  $user['name'],                  "###EMAIL###"  =>  $user['email']              ];              $content  .=  $this-­‐>cObj-­‐>substituteMarkerArray(                  $rowTemplate,  $markers              );          }            $markers  =  ['###USERS###'  =>  $content];          return  $this-­‐>cObj-­‐>substituteMarkerArray($mainTemplate,  $markers);      }  }  

Page 29: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
Page 30: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

demo time

CC BY Kenny Louie https://www.flickr.com/photos/kwl/4743024076

Page 31: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

try it https://github.com/mittwald/flow-metamorph

Page 32: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
Page 33: T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow

http://creativecommons.org/licenses/by-sa/4.0/

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.