Skip to content
Puja edited this page Sep 23, 2013 · 1 revision
        **Fluid : Cut dependencies on Flow**

Aim of the project :

Fluid, which is the TYPO3 template engine for TYPO3 Flow and CMS/Extbase ,is currently having heavy dependencies on TYPO3 Flow (formerly known as Flow3) as a framework.

This project was aimed to make Fluid a standalone, in order to be able to use it with other frameworks as well (viz. Symfony , Zend etc.).

This project report contains an outline of everything I learnt and did in these 3 months! :)

About Fluid :

In many MVC systems, View doesn't have a lot of functionality. That is the main power of Fluid. View is basically responsible for the visual presentation of the data provided by the controller.

In case of Fluid, the next generation template engine,the View is controlled by a special _TemplateView _(/TYPO3/Fluid/View/TemplateView) , which instantiates the TemplateParser, resolves the template HTML file and renders the template afterwards. View is one of the most important properties of Fluid.

_ViewHelpers _(/TYPO3/Fluid/ViewHelpers) , as the name itself says, 'Helps' the ‘View'. Help in the sense,the ViewHelpers contain the main output logic of the Fluid.

The _ViewHelpers _are invoked by using XML tags in the template,and are implemented as PHP classes, i.e., each ViewHelpers is defined as a separate PHP class. ViewHelpers are reusable and most of them work well in both frontend and backend and are relevant for any type of template.

This is an important difference between Fluid and other template engines, i.e., the way ViewHelpers are implemented in them.

The tag and ViewHelpers are like the building blocks of Fluid(along with View ofcourse,so getting them on the way was my first goal).

Approach:

Initially, the plan was to integrate Fluid with Symfony2, observe the problems hence occurred and work on the them. The github Repository proved to be instrumental on the way,as it was a project done in the same direction. It was a month from then that we started with the new approach (which is yet to be worked upon a bit):

The main TYPO3.Fluid package is split into 2 packages (I call them as the Fluid package and the Base package, but obviously you can name the rendering package anything that suits you, be it TYPO3.Fluid.Base or TYPO3.Flow_id ;-) )

The two packages are :

1. TYPO3.Base : This is the base, 'non-Flow' rendering package which does not take any dependencies from TYPO3 Flow, but performs almost all of the important functions of TYPO3.Fluid.

2. TYPO3.Fluid : This is the connecting (adaptor) package, i.e., the package that links the Base package to the Flow package and contains all the Flow dependencies Fluid needs to have.

Let us understand this with the help of the following example :

Initially , \TYPO3\Fluid\Core\Compiler\Templates\Compiler\TemplateCompiler has the following dependency:

@Flow\Scope (line no. 17 and line no. 39)

So,now, here's what the two packages will contain for this particular file :

TYPO3.Base

  • TemplateCompiler without the Flow\Scope
  • Include all the major functions that Fluid can perform without Flow.

TYPO3.Fluid

  • Extend the class to \TYPO3\Base\Core\Compiler\TemplateCompiler and link it with the related Flow dependencies as well (all the scope annotation and cache) .

Similarly, everything that needs a dependency is added to the TYPO3.Fluid package, and every other thing which can function well without Flow is kept in the TYPO3.Base package.

Kickstarting a package :

The TYPO3.Kickstart package too is defined as a Flow package,which provides template-based scaffolding for generating an initial layout of packages, controllers,views etc.

When a TYPO3 Flow package is kickstarted , the “TYPO3.Kickstart” package comes into action first. It sends some essential data to Fluid (TYPO3.Fluid),mainly, to the the View. The View then calls the ViewHelpers and the Flow package as well (the major dependencies).

So, basically , it looks like :

_TYPO3.Kickstart calls TYPO3.Fluid  and _
_TYPO3.Fluid calls TYPO3.Flow._

Now, this project is intended to make this relation look like :

 _TYPO3.Kickstart calls TYPO3.Fluid  and  _
 _TYPO3.Fluid calls TYPO3.Base as well as TYPO3.Flow (the dependencies)_.

Steps involved:

1. The first step was to study all the dependencies involved. The major ones being :

    * \TYPO3\Flow\Mvc\View\ViewInterface

    *  \TYPO3\Flow\Mvc\Controller\ControllerContext

    * \TYPO3\Flow\Object\ObjectManager

    * \TYPO3\Flow\Annotations

    * \TYPO3\Flow\Mvc\ActionRequest

    * \TYPO3\Flow\Core\Booting\Sequence

    * \TYPO3\Flow\Http\RequestHandler

    * \TYPO3\Flow\Core\Booting\Scripts

    * \TYPO3\Flow\Utility\Files

    * \TYPO3\Flow\Exception

    * \TYPO3\Flow\Core\Bootstrap

    * \TYPO3\Flow\Package\Metadata

    * \TYPO3\Flow\Package\PackageManager etc.

2. The main objective was to work with all the Class files.

3. TYPO3.Fluid     is kept as the adapter package, and all the contents of current     TYPO3.Fluid is copied into TYPO3.Base . Then, the code parts that have Flow dependencies are moved into the Fluid package, and coding properly to avoid any errors.    
  1. Created 2 different repositories for both the packages : (TYPO3.Fluid ,the adapter package and TYPO3.Base,the rendering package) (to make testing easier).

Goals:

_**TYPO3.Base**_  : In  the end, the rendering package (Base) should run without Flow and can render a template.    

(template rendered => Success!)

_**TYPO3.Fluid**_ : must do all the necessary linking of the rendering package to the Flow package. This package need not have all the functionalities of  Fluid, as the TYPO3.Base package is supposed to perform those  functionalities. The main function of this package is linking, as  demonstrated in the previous example.

Current Status:

* The rendering package (TYPO3.Base) contains all the basic functionalites that were contained in      the    TYPO3.Fluid package previously, which can perform despite of Flow.

* TYPO3.Base package is free from all the Flow dependencies.

* The TYPO3.Base package gets autoloaded. (/Quickstart/Packages/Framework/TYPO3.Base/composer.json).

* TYPO3.Fluid , (previously the rendering package, now an adapter package)

links the Fluid package to Flow. It extends classes from the fluid package and adds the corresponding Flow dependencies.

Yet to do :

Some work yet needs to be done. 

(I think some 15-20 days will still be required to get this done.)

* If desired, a package.php file (/Quickstart/Packages/Framework/TYPO3.Base/Package.php) can be created for the rendering Base package. But that is not necessary.

    (P.S.- all the other Framework packages are already defined as ‘Flow’ packages.)

* Further, if wanted, some work can be done on Framework localization, and widgets.
Clone this wiki locally