ZF-Commons / ZfcUser

A generic user registration and authentication module for ZF2. Supports Zend\Db and Doctrine2. (Formerly EdpUser)
BSD 3-Clause "New" or "Revised" License
498 stars 343 forks source link

Use Explicit 'ZfcUser\Service\User' Event manager's identifier #477

Open alihammad-gist opened 10 years ago

alihammad-gist commented 10 years ago

Right now zfcuser extend's ZfcBase's EventProvider in ZfcUser\Service\User and the Event Manager is assigned Identifiers dynamically one of which is usually ZfcUser\Service\User untill you override the service locator service zfcuser_service_user with a custom service and you can't assign listeners to ZfcUser\Service\User 's event manager using shared event manager because ZfcUser\Service\User identifier is dynamically changed with custom service's name you wrote. It would be benifitial if ZfcUser\Service\User is exlicitly added to its event manager's identifiers

$this->getEventManager()->addIdentifiers('ZfcUser\Service\User');
ojhaujjwal commented 10 years ago

+1

adamlundrigan commented 9 years ago

@Danielss89 is this something that should be ZfcUser's concern, or the concern of the class doing the extending?

This can be fixed in ZfcUser by adding this to Zfcuser\Service\User:

/**
 * @var array
  */
protected $eventIdentifier = array(__CLASS__);

However, the extending class could just as easily do this instead:

/**
 * @var array
  */
protected $eventIdentifier = array('ZfcUser\Service\User');

I'm in favor of the latter + a blurb of documentation somewhere stating that if you override the service you must add the stock service's fqcn to the event manager's identifier set.

claytondaley commented 9 years ago

Unless there's a specific case against it, I vote to be proactively extension friendly. A new module is overwhelming enough without having to pick every single gotcha out of the documentation.