[Flow] How to determine the currently called controller

Christian Loock brainshack at gmail.com
Mon Mar 10 12:58:56 CET 2014


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