[FLOW3-general] Use ActionController for Web Requests and CLI, when using Fluid as Templating Engine for Web Requests.

Bastian Waidelich bastian at typo3.org
Fri Sep 17 11:57:31 CEST 2010


Thomas Fritz wrote:

Hi Thomas,

> how can i then use the same controller with the
> same logic for different Request Types?

You can handle your request differently based on the format.
At least that's how we currently do it to serve extdirect, json and html 
requests in one controller. See
http://git.typo3.org/FLOW3/Packages/TYPO3.git?a=blob;f=Classes/Controller/ContentController.php;h=a6f76b4fe827091349d2a78b7a4f5e826e86ab5f;hb=HEAD 
[line 97ff]

$this->request->getFormat() should by default return 'txt' for CLI- and 
'html' for web requests.

If you really have the same logic no matter what kind of request, you 
can skip the above and only create a custom view for the CLI requests 
(see ActionController::resolveView()).
You could e.g. write a generic TxtView that nicely outputs the assigned 
view variables (compare JsonView) - if it works feel free to share it 
with us ;)


> What is the proposed way when i have one
> or more ActionControllers for both Web and CLI Requests and i want to get
> input from the user [...]
> I want  to ask the user within the action and read from
> stdinput to get the arguments.

AFAIK that's not (yet) supported. Probably the CLI\RequestBuilder would 
be the place to implement this..

Best,
Bastian


More information about the FLOW3-general mailing list