[Flow] How to determine the currently called controller

Adrian Föder adrian at foeder.de
Mon Mar 10 13:14:38 CET 2014


Perfect.
For such quick issues you're welcome to #typo3-flow in the freenode IRC 
channel, you almost always will get a "real time answer" there.

Am 10.03.2014 12:58, schrieb Christian Loock:
> That was exactly the kind of magic I was hoping for :)
>
> Thanks a lot
>
>
> 2014-03-10 12:50 GMT+01:00 Adrian Föder <adrian at foeder.de>:
>
>> Hi Christian,
>>
>> it's rather simple: in every ViewHelper you have a ControllerContext
>> (instance of \TYPO3\Flow\Mvc\Controller\ControllerContext). With this,
>> you can fetch the Request and call ->getControllerObjectName on it, for
>> example.
>>
>> So,
>>
>> $this->controllerContext->getRequest()->getControllerObjectName()
>>
>>
>> Or, in even more detail:
>>
>> $request = $this->controllerContext->getRequest();
>> if ($request instanceof \TYPO3\Flow\Mvc\ActionRequest) {
>>          $request->getControllerPackageKey();
>>          $request->getControllerName();
>>          $request->getControllerActionName();
>> }
>>
>> HTH,
>>
>> Adrian
>>
>>
>> Am 10.03.2014 09:22, schrieb Christian Loock:
>>
>>> Hello,
>>>
>>> inside my ViewHelper i need to know which Action/Controller/Package is
>>> currently being called (to determin the active state of a Menu item).
>>>
>>> I tried to create an ActionRequest like this:
>>>
>>> \TYPO3\Flow\Http\Request::createFromEnvironment()->createActionRequest()
>>>
>>> But the ActionRequest will always return NULL when i try to call
>>> controller
>>> Information.
>>>
>>> What is the best way to get those informations outside of a
>>> ActionController?
>>>
>>> Thanks in advance,
>>>
>>> Christian
>>>
>>>
>> _______________________________________________
>> Flow mailing list
>> Flow at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>



More information about the Flow mailing list