jpcercal/doctrine-bundle

View on GitHub
src/DependencyInjection/Compiler/CompilerDoctrineConnectionPass.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

/*
 * This file is part of the Cekurte package.
 *
 * (c) João Paulo Cercal <jpcercal@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Cekurte\DoctrineBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
 * CompilerDoctrineConnectionPass
 *
 * @author João Paulo Cercal <jpcercal@gmail.com>
 *
 * @version 1.0
 */
class CompilerDoctrineConnectionPass implements CompilerPassInterface
{
    /**
     * @inheritdoc
     */
    public function process(ContainerBuilder $container)
    {
        if ($container->hasDefinition('doctrine.dbal.dynamic_connection') && $container->hasDefinition('session')) {
            $container
                ->getDefinition('doctrine.dbal.dynamic_connection')
                ->addMethodCall('setSession', array(new Reference('session')))
            ;
        }
    }
}