[TYPO3-mvc] RFC: Extensible Controllers

Sebastian Gebhard sebastian.gebhard at googlemail.com
Sun Aug 9 14:39:09 CEST 2009


Hi folks,

Currently the controllers define their actions through dedicated 
functions: indexAction(), showAction(), editAction() etc. Now if you 
want to add actions from "outside" the only possibility is XCLASSING the 
controller.

It would be great if there was a cleaner way for extending controllers.

Here's an example with my proposal:
In a blog extension ('ablogextension') there's a controller Post with 
the actions index and show und compose (therefore it has the functions 
indexAction(), showAction() and composeAction() ).

Now there's a second extension ('editposts') that wants to add actions 
to the Post Controller.

In the ext_localconf.php of the new extension:

$foreignExtKey = 'ablogextension';
Tx_Extbase_Utility_Plugin::addForeignAction(
	$_EXTKEY,
	$foreignExtKey,
	'Post'
	'Tx_Editposts_Controller_Post'
)

Now if an action is called which is not available in the original Post 
controller then Extbase looks up Tx_Editposts_Controller_Post. It could 
contain an editAction() for example. It also contains the Fluid template 
for that new action.

The advantage to XCLASS is of course that a controller can be extended 
multiple times and add different actions every time.

I hope you get the point - what do you think?


More information about the TYPO3-project-typo3v4mvc mailing list