[TYPO3-dev] XCLASS conflict examples

Elmar Hinz elmar.DOT.hinz at team.MINUS.red.DOT.net
Sun Feb 12 10:50:40 CET 2006


tapio schrieb:
> that is not enough in certain situations. IMO one of the most difficult
> area is interface control (alt_doc.php, db_layout.php,
> class.tx_cms_layout.php etc. ). In order to get interface-related
> plugins to work together it is necessary to rewrite much source because
> handling of button related actions are different. You must rewrite the
> code for individual action buttons or make conditions. Link wraps have

You can overrite every single function of the origingal class in an XCLASS. You
even can provide a completly different class as long as the public accessible
function provide the same interface.

I already said this in the thread "Defending the XCLASS, proposing smaller
classes". I must add, that we do not only need smaller classes but also smaller
functions.

If we have one action controller that contains a switch-case construct it is
difficult to extend by 2 differnet extensions, that both want to add new
actions. They get into conflicts by extending the same controller function.
That's the same for hooks, services, XCLASS. It doesn't depend on the
technology. It depends on the style of coding.

Also for the controller we need flexiblity to extend it by modularizing the
controller function into multiple functions. One for each action.

Michael Scharkow has proposed for ECT a generic dispatcher instead of a concrete
switch-case. This is my very simplefied adaption for easy understanding of the idea.

function main(....){
 [...]
 if ($controllerFunction = $this->controllers[$action]) ){
  $out = $this->$controllerFunction(....);
 } else {		
  $out =  $this->error404();
 }
 [...]
 return $out;
}

One step further you could even use one class for each action.

function main(....){
 [...]
 if ($obj = $this->getControllerObject($action)) ){
  $out = $obj->main(....);
 } else {		
  $out =  $this->error404();
 }
 [...]
 return $out;
}

You can flexibly register new controllers for new actions. This is usefull for
FE and BE in the same way.




Best Regards

Elmar




More information about the TYPO3-dev mailing list