[FLOW3-general] Use ActionController for Web Requests and CLI, when using Fluid as Templating Engine for Web Requests.
Georg Ortner
go at simplaweb.at
Fri Sep 17 15:05:55 CEST 2010
Wouldn't it be nice to have that functionality right in the MVC framework?
My suggestion is that if there is a method called e.g. showActionJson() it
will be called if it's a json request or showActionCli() for the command
line and so on. And if there isn't an appropriate action especially for that
request type the showAction() will be called. I think this would make the
code easier to read and I don't think it would be such a problem to
implement this. I could dig a little and see if I can do it. Just want to
know your opinion first if this does make sense or does it raise other
issues?
Regards
George
On Fri, Sep 17, 2010 at 5:57 AM, Bastian Waidelich <bastian at typo3.org>wrote:
> 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
>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>
More information about the FLOW3-general
mailing list