Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override the User type so I can implement an interface #66

Open
mattsnowboard opened this issue Nov 12, 2015 · 0 comments
Open

Override the User type so I can implement an interface #66

mattsnowboard opened this issue Nov 12, 2015 · 0 comments

Comments

@mattsnowboard
Copy link

I need the users loaded by this bundle to implement an interface so I can use them in place of my other users loaded by FOSUserBundle.

I was able to almost do this by making a child bundle to override the Entitiy/User.php file with a new one. I had to just copy-paste the entity from the bundle and add my interface and implement the methods. The problem is, since the Doctrine mapping is already in the annotations in this bundle, I now have two entities that use the same table.

I added resolve_target_entities to my config which seemed to work:

doctrine:
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager:   default
        entity_managers:
            default:
                connection: default
                mappings:
                    StudyMainBundle: ~
                    FOSUserBundle: ~
            wordpress:
                connection: wordpress
                mappings:
                    KayueWordpressBundle: ~
                    StudyWordPressBundle: ~
        resolve_target_entities:
            Kayue\WordpressBundle\Entity\User: Study\WordPressBundle\Entity\User

The problem is that my unittests/functional tests always load fixtures and Doctrine doesn't like that it finds two entities that map to the table wp_users.

Could you make some change so that users can be overridden? Maybe use the MappedSuperclass pattern that FOSUserBundle does https://symfony.com/doc/1.3.x/bundles/FOSUserBundle/index.html ? If there is some other way I can accomplish this, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant