You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use several database connections and manually map our entity managers. This causes problems when we don't want the OAuth entities to exist in the main entity manager.
As a workaround I added a compiler pass which while not the prettiest of solutions but it allows everything to work as intended.
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class OAuthCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$replaceEmServices = [
'oauth2.user_provider',
'oauth2.scope_manager',
'oauth2.storage.client_credentials',
'oauth2.storage.authorization_code',
'oauth2.storage.user_credentials',
'oauth2.storage.access_token',
'oauth2.storage.refresh_token',
'oauth2.storage.scope',
'oauth2.client_manager',
];
//Set this to the service id of your entity manager
$newEntityManager = 'doctrine.orm.connect_entity_manager';
foreach ($replaceEmServices as $serviceId) {
if ($container->hasDefinition($serviceId)) {
$definition = $container->getDefinition($serviceId);
$reference = new Reference($newEntityManager);
$definition->replaceArgument(0, $reference);
}
}
}
}
The text was updated successfully, but these errors were encountered:
Allow configuration to switch entity managers.
We use several database connections and manually map our entity managers. This causes problems when we don't want the OAuth entities to exist in the main entity manager.
As a workaround I added a compiler pass which while not the prettiest of solutions but it allows everything to work as intended.
The text was updated successfully, but these errors were encountered: