I read the documentation on Strategies and it seems the code below is valid at least in Zend Framework 2. Of course, I tested it.
public function onBootstrap(EventInterface $e)
{
$t = $e->getTarget();
$t->getEventManager()->attach(
$t->getServiceManager()->get('ZfcRbac\View\Strategy\UnauthorizedStrategy')
);
}
But when using the Zend Framework 3, it no longer works. It will show the error below:
Fatal error: Uncaught TypeError: Argument 2 passed to Zend\EventManager\EventManager::attach() must be callable, object given, called in /var/www/sub.domain.tld/html/module/Application/src/Module.php on line 20
So basically I am stuck right now. Can you at least point out or guide me to the right direction?
I have to ditch the
UnauthorizedStrategy
class. Basically, I copied the code fromonError
method fromUnauthorizedStrategy
class and modified to fit my needs.