Nov 21, 2014 Tag: Extbase

Extend an Extbase Domain Model “On the Fly”

Thanks to Sebastian Fischer it can be easy now to extend the domain model of an existing extension. Sebastian presented his TYPO3 CMS extension ‘extender’ at the T3CRR 2014 in Essen. This post gives a very short description and howto.

Updated on Mar 11, 2015

See also: About Extbase

Overview:

Problem

Sometimes the domain model of an existing extension doesn’t cover all your needs and you wish to add extra functionality without having to touch the original code. There is good news: ‘ext:extender’ is available from TER and lets you do exactly that.

How it works

Here is a short example:

  1. Let’s take ‘FrontendUser’ as an example for a domain model you want to enhance. It is part of the sf_register extension.’ So go ahead and install that extension. There is nothing special to prepare here.

  2. Install the extender extension. Again: There’s nothing to change here.

  3. Create a new extension ‘ew_sfregister_extended’. This is where all your code for the new functionality goes.

  4. Add your additional classes that inherit from the original ones. Add properties, getters and setters as needed.

    Note: Only add properties, getters and setters that are not part of the original model!

  5. Add TCA, ext_tables.sql and more as needed.

  6. Add a dependency for ‘extender’ in file ext_emconf to garantee that ‘extender’ is installed whenever ‘ew_sfregister_extended’ is installed.

  7. Now add all the magic with this line in ext_localconf.php:

    $GLOBALS['TYPO3_CONF_VARS']
       ['EXTCONF']['sf_register']['extender']
       ['FrontendUser']['ew_sfregister_extended'] =
       'EXT:ew_sfregister_extended/Classes/Domain/Model/FrontendUser.php';
    
  8. Clear the system cache.

Enjoy!

Example Code

The example is based on Sebastian’s real life extension ‘ew_sfregister_extended’ that can be found at Github: https://github.com/evoWeb/ew_sfregister_extended

Thank you very much!

Previous topic

Basic Installation of Sphinx and Ablog

Next topic

Howto SSH

Tags

Archives

Languages

Recent Posts

This Page