Using the active controller inside a beforeExecuteRoute event

Hey there,

I noticed that in an beforeExecuteRoute event, the controller is already initialized (i.e. the method initialize() was loaded and the controller exists somewhere). How can I access it from within an event handler if that handler is a Phalcon\Mvc\User\Plugin?

Thanks in advance!

Best, Philipp


Hi Phillpp, check this example out,

It uses the current controller in a beforeExecuteRoute event

Hey @phalcon,

thanks for the link, I already got that far ;). But what I couldn't figure out is how to access the controller object of the currently active controller from inside that plugin.

e.g. $this->controller->element from MyController { $element = 123; }