FriendsOfSymfony/FOSUserBundle — Issue #558: Issue with non default entity manager
Author: pandur
Created: 2012-03-04 17:09:13+00:00
State: open

Hi,

following suggestion found here:

http://groups.google.com/group/symfony2/browse_thread/thread/7d0451a3e23d560f

I've set constraint in my User entity:

* @Unique\UniqueEntity(fields={"username"})
*/
class User extends BaseUser implements EncoderAwareInterface
{

but I got Exception while trying to submit registration form:
Class Acme\TestBundle\Entity\User is not a valid entity or mapped super class.

After a while I've figured out that possible cause is my setting in config.yml:

fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Acme\TestBundle\Entity\User
model_manager_name: test <--------------------------------------- correct name for entity manager

where
doctrine:
dbal:
default_connection: legacy
connections:
legacy:
(..)

test:
(...)

orm:
auto_generate_proxy_classes: %kernel.debug%
# auto_mapping: true
default_entity_manager: legacy <------------------------------------- correct default entity manager

Changing default_entity_manager to 'test' fixes the problem - I can succesfully submit the registration form and doctrine's constraint works as expected. Looks that some routine does not use default_entity_manager.