[Flow] How to determine the currently called controller

Adrian Föder adrian at foeder.de
Mon Mar 10 12:50:31 CET 2014


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
>



More information about the Flow mailing list