Details
-
Improvement
-
Resolution: Fixed
-
High
-
Engineering tracked issues
-
Ventoux Sprint 5
Description
Follow up of EZP-22151.
Repository configuration regarding DBAL connection should integrate correctly with DoctrineBundle.
Benefits
- More standard approach, Symfony wise.
- Allow developers to seamlessly use Doctrine ORM
- Simplifies configuration in ezpublish.yml
Solution
DoctrineBundle uses the concept of connections which are re-usable. Idea is to make it possible to use a defined connection:
# Using Doctrine default connection doctrine: dbal: driver: pdo_mysql host: localhost port: 3306 dbname: ezdemo user: root password: root charset: UTF8 ezpublish: repositories: # Takes all default values (engine: legacy, connection: default) main: ~ system: ezdemo_group: # Optional, if not provided, will take the first defined repository by default repository: main ##### # Using a named Doctrine connection doctrine: dbal: default_connection: default connections: default: dbname: Symfony2 user: root password: null host: localhost my_connection: dbname: customer user: root password: null host: localhost ezpublish: repositories: main: # legacy => Legacy storage engine engine: legacy connection: my_connection
Also, if no connection is configured, it would use the default one.
For a developer to reuse this connection in his code for his ORM needs, it would be as simple as:
namespace Acme\AcmeTestBundle\Controller; use eZ\Bundle\EzPublishCoreBundle\Controller; class SomeController extends Controller { public function indexAction() { $em = $this->getDoctrine()->getManager( 'my_doctrine_connection' ); } }