[TYPO3-core] RFC #13313: ExtDirect API

Stefan Galinski stefan.galinski at gmail.com
Wed Jan 20 22:33:07 CET 2010


Steffen Kamper wrote:

> Why not use "forceOnTop" for pageRenderer - that's how it's done in
> other setters, so it would be unique. I also prefer the boolean instead
> key strings "TOP" etc.

Thanks for the feedback! I will add a new version of the patch tomorrow.
 
> Is there a small application for testing the API? Something like this is
> needed for testing, i think you have something.

You can install the demo extension which you can find in the bugtracker. If 
you need some more heavy stuff, you can download the current t3uxw 
repository and look at the new pagetree. ;-)

At least it's not really difficult. We introduced a new configuration array 
that holds pairs of a javascript object name as key and a reference to an 
existing php class as the value.

Example (taken from the demo extension):
$GLOBALS['TYPO3_CONF_VARS']['BE']['ExtDirect']['TYPO3.Demo.Test'] = 
'typo3conf/ext/extdirecttest/class.tx_extdirecttest_test.php:tx_ExtDirectTest_test';

The configuration array is processed by the API generator that provides 
ExtJS the needed informations about the available methods and parameters. By 
default we are providing all methods inside the TYPO3.Backend namespace (all 
keys inside the configuration array that starts with TYPO3.Backend). If you 
want another namespace loaded, because you need the functionality inside the 
frontend or a special backend module, you need to call the API generator 
with the get parameter "namespace" yourself. The following example provides 
all methods inside the classes of the TYPO3.Demo namespace.

Example (taken from the demo extension):
ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Demo

The referenced classes at the server side are simple containers with the 
methods, you can access from the client side. The router part of this patch, 
dispatches the incoming calls from ExtDirect to there server side 
equivalents.

Example (server side):
class tx_ExtDirectTest_test {
  public function sayHello() {
    return 'Hello!';
  }
}

Example (client side):
TYPO3.Demo.Test.sayHello(function(result) {
  alert(result);
});

As you can see, the class isn't used at the client side call. Instead we are 
using the defined javascript object name that was introduced in the 
configuration array.

I hope this helps to understand the stuff. ;-)

--
Stefan Galinski


More information about the TYPO3-team-core mailing list