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?
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