Advanced Provider Extensions · Custom Flux Controllers · Creating Flux Controllers

4.1.2 Creating custom Flux controllers

FluidTYPO3 File contexts, Controllers

A Flux controller is almost exactly identical to a standard ActionController in its most basic form:

namespace FluidTYPO3\Fluidcontent\Controller;

use FluidTYPO3\Flux\Controller\AbstractFluxController;

 * My custom ContentController to render my package's Content templates.
 * @package Myextension
 * @subpackage Controller
class ContentController extends AbstractFluxController {


Once created, the class will automatically be used by Fluid Powered TYPO3's features which render the Content type (in other words: fluidcontent elements from your own package). Initially your controller will not actually perform any actions - all it does (since having an empty class body) is become instanciated and use functions inherited from the parent class.

Special initialisation methods

On custom Flux Controllers a few additional initialisation methods have been added in order to get a greater degree of control and clarity over the creation of the special context Flux needs when rendering Controller actions. In order of execution, these methods are:

  1. initializeProvider, which in the base class simply sets the Controller's desired table and field name relationship.
  2. initializeSettings, which in the base class fills $this->settings (TypoScript and Flux form variables), $this->setup (view paths from TypoScript for your extension) and $this->data (the Flux form variables only, excluding TS values).
  3. initializeOverriddenSettings, which takes care of adjusting $this->settings with overrides if any should be performed.
  4. initializeViewObject, which is the new counterpart to initializeView which is taken over by Flux - among other things it can set the template path and filename in the Provider if the controller explicitly defines one to use.
  5. initializeViewVariables, which can be used to assign variables to your view - variables, which will be assigned in every action (and which can then later be re-assigned from within each Controller action).

The methods are all called from the initializeView method on the Flux controller class - you should never override this class without also either calling all the appropriate intialisation methods OR remembering to call parent::initializeView($view). Overriding these methods (and taking a look in the original method, if necessary calling parent::$methodName() in the top of your overridden method to ensure the context gets created properly) can allow you to control many detailed aspects of how your View and variables are prepared.

Jump to...