I won't be claiming this is a best practice, but this is how I managed to handle the situation! First - big thanks to answer in this question ZF2: Custom user mapper for ZfcUser module.
So, I did:
- Added configuration of
zfcUser/Entity
inzfc-user.global.php
autoload:'zfcuser' => array( 'tableName' => 'users', 'user_entity_class' => 'Application\Entity\User' ),
- Added my classes for
Entity\User
,Mapper\User
andMapper\Hydrator
into mysrc/Application
Entity and Mapper subfolders. - Updated those classes namespaces to be my
Application\Entity
andApplication\Mapper
Added this configuration to
getServiceConfig
function of myModule.php
:'factories' => [ 'zfcuser_user_mapper' => function ($sm) { $mapper = new Mapper\User(); $mapper->setDbAdapter($sm->get('Zend\Db\Adapter\Adapter')); $mapper->setEntityPrototype(new Entity\User()); $mapper->setHydrator(new Mapper\UserHydrator()); return $mapper; }, ]
- Updated my classes dependencies to use
ZfcUSer
and started myEntity\User
asextends \ZfcUser\Entity\User implements \ZfcUser\Entity\UserInterface
.