[Flow] Accessing settings in command-line controller

Steffen Wickham steffen at gaming-inc.de
Thu Apr 10 15:00:05 CEST 2014


As Christian mentioned: You should extract the dependencies of your
abstract controller to an external class (or maybe more) and inject them
into your abstract and command controller.

I did something similar in my latest project. I need some informations
regarding the TYPO3.TYPO3CR in my web view and a command. So I moved my
redundant code to a Service class names "ContentRepositoryService" where
I put all my stuff in it, like fetching a specific node in the correct
context and filtering a content tree for specific types, and inject this
class in the abstract and command controller.

And for the Settings.yaml problem in your CommandController do it like
Christian said: Inject the settings in your controller manually and
access it like every other array. This works fine for me.

Greetings
Steffen



Am 10.04.2014 07:59, schrieb Christian Loock:
> You settings should be accesible by just injecting it. Add a
> injectSettingsmethod to your controller, so the settings can be
> injected. As far as the Abstract Controller goes, I used to do this
> aswell, but am currently working on eleminating this sort of
> dependency in my code. You might want to put those constants and
> variables inside a seperate class, which you then could just load
> inside you controllers. Also, ViewHelpers can help do a lot of the
> work that you would want to do in a abstractController itself. As far
> as loading the AbstractController inside a CommandController goes, you
> can't really. Unless you make those variables static.
>
>
> On 09.04.2014 18:38, Cornel Widmer wrote:
>> Hi folks
>>
>> Maybe someone of you can help me out with this problem. I've a some
>> paths written in my Settings.yaml and a lot of constants and
>> variables in an abstract controller for my flow application.
>>
>> Now, I want to access some of them (paths from settings and variables
>> from the abstract controller) in a command line controller. But
>> obviously the retrieving from Settings.yaml does not work out of the
>> box.
>>
>> Logically I cant acces the variables of my abstract controller as I
>> can not extend from the abstract controller.
>>
>> Can someone point me in the right direction to sail around these
>> design flaws of my application. I really want to learn, so every tipp
>> is very appreciated.
>> _______________________________________________
>> Flow mailing list
>> Flow at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>



More information about the Flow mailing list