Closed wimvds closed 10 years ago
The parent mapping is not loaded because there is no driver configured for the FOSUserBundle (this is intentional), so the CompilerPass for registering these mappings is not registered either.
Using multiple connections is possible, but has no been tested before so guess thats why this was not discovered before.
I need to update the documentation to mention this, and properly add the enabling of these loaders to the user-Bundle generation script so it can be done automatically.
For now you can update the Bundle class with.
<?php
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
class AcmeAdminBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$this->addRegisterMappingsPass($container);
}
/**
* @param ContainerBuilder $container
*/
private function addRegisterMappingsPass(ContainerBuilder $container)
{
$r = new \ReflectionClass('FOS\UserBundle\FOSUserBundle');
$mappings = array(
realpath(dirname($r->getFilename()) . '/Resources/config/doctrine/model') => 'FOS\UserBundle\Model',
);
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, array('acme_admin.model_manager_name')));
}
}
And do the same for the ClientBundle.
Cool, thanks. I ended up moving the client user entity over for the time being, and only store their private info in the separate table. I'll try to find out if that approach works during my holiday in 2 weeks (really swamped at the moment, and lots of stuff to do in the meantime).
I also found another issue with your fork, the model_manager_name for acme_client was set to default. You need configure the model_manager_name.
in app/config.yml
acme_client:
model_manager_name: client
Or else it will default to what is configured in the AcmeClientExtension
which in this case is 'default'.
Closing now that there is a PR.
I tried using the bundle today, I have 2 entity managers, both using orm, but with different databases and users (stored in different bundles to make it easier to separate them with doctrine). My entities use doctrine annotations, and extend FOS\UserBundle\Model\User.
When I create the schema for the databases only the custom fields I added are created in the second database, but all of the default FOSUserBundle fields (username, email, salt ...) are missing. In the default DB, everything is ok. So does the bundle actually support multiple databases or did I just do something wrong?
The simple test case I used can be found here : https://github.com/wimvds/RollerworksTest.