php - Zf2 Event practice (changeable?)


i have an question about practice of events in zf2. As best practice we have to use changeable interfaces by default, to inject objects dynamicly.

But, whats with Events? Should events be injectable? For example an Authentication Service within an AuthenticationEvent. Is it better to call the AuthenticationEvent directly or via get/set?


$this->getEventManager()->trigger('auth_pre', __CLASS__, new AuthEvent($params));


$eventAuth = $this->getAuthEvent();
$this->getEventManager()->trigger('auth_pre', __CLASS__, $eventAuth);


People are also looking for solutions to the problem: php session, value display dont work


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.