Here's my code, in Module.php:
public function onBootstrap(MvcEvent $mvcEvent)
{
$sm = $mvcEvent->getApplication()->getServiceManager();
$myServiceEM = $sm->get('MyModule\Service\MyService')->getEventManager();
$myServiceEM->attach(
'myevent.post', ['MyModule\Controller\MyController', 'myFunction']
);
}
And here's myFunction()
in MyModule\Controller\MyController:
public function myFunction(Event $e)
{
$myTestFunc = $this->getMyTestFunc();
}
But when I call getMyTestFunc()
function this error appears:
Fatal error: Uncaught Error: Using $this when not in object context