[TYPO3-ect] TS Action chains for SPL objects
Steffen Kamper
steffen at sk-typo3.de
Tue Aug 7 22:23:03 CEST 2007
Hi Elmar,
"Elmar Hinz" <elmar07 at googlemail.com> schrieb im Newsbeitrag
news:mailman.1.1186514147.12957.typo3-team-extension-coordination at lists.netfielders.de...
>> Hi Steffen,
>>
>> well there are several resons. A write them down as a simple list.
>>
>> * Technically it would be an controller extending tx_lib_controller.
>> * Similar concept to successfull JAVA struts, but goes some steps
>> further.
>> * The vision helps to keep the API of SPL objects simple and stringent.
>
>
> I now have an example, how it helped me to simplify in the SPL objects
> API:
>
> Old bananas list action:
>
> public function defaultAction() {
> // finding classnames
> $modelClassName =
> tx_div::makeInstanceClassName('tx_bananas_models_board');
> $listClassName =
> tx_div::makeInstanceClassName('tx_bananas_views_list');
> $entryClassName =
> tx_div::makeInstanceClassName('tx_bananas_views_entry');
> $translatorClassName =
> tx_div::makeInstanceClassName('tx_lib_translator');
>
> // a simple processing chain
> $model = new $modelClassName($this);
> $model->load();
> $view = $model->toObjectOfObjects($listClassName, $entryClassName);
> $view->render($this->configurations->get('listTemplate'));
> $translator = new $translatorClassName($this, $view);
> return $translator->translateContent();
> }
>
> New bananas list action:
>
> public function defaultAction() {
> $model = $this->makeInstance('tx_bananas_models_board');
> $model->load();
> $view = $this->makeInstance('tx_bananas_views_list',
> $model);
> $view->castElements('tx_bananas_views_entry');
> $view->render('listTemplate');
> $translator = $this->makeInstance('tx_lib_translator',
> $view);
> return $translator->translateContent();
> }
>
> You see it now could probably directly be translated to TS:
>
> defaultAction {
> START = model
> model = tx_bananas_models_board
> model.do.1 = load
> model.go.next = view
> view = tx_bananas_views_list
> view.do.1 = render
> view.do.1.1 = listTemplate
> view.go.next = translator
> translator = tx_lib_translator
> translator.1 = translateContent
> translator.return = content
> }
>
> Well, there is stell an issue with the return syntax.
>
> Regards
>
> Elmar
Ah I see. That's really interesting. You call it defaultAction, that
implicies that there are othere Actions possible.
So does the TS replace the php-code or is it an alternative ?
Also i don't see - how are parameters handled in TS ? Looks like you do it
in array, where does return values processed ?
How does simple switch-case works with the TS ?
Sorry for asking so lot, but i think the TS in general needs some more
functionality to work on such high level. In this case TS is used like a
programming language, and i wouldn't call TS a programming language (atm).
vg Steffen
More information about the TYPO3-team-extension-coordination
mailing list