php - Zf2 Event practice (changeable?)

276

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?

Example:

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

or

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

regards

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

Source

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.