[PR #238] [CLOSED] Add Configuration::setDefaultMetadataDriverImpl() method for convenience. #7903

Open
opened 2026-01-22 15:57:28 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/238
Author: @sobstel
Created: 12/23/2011
Status: Closed

Base: masterHead: master


📝 Commits (1)

  • 7c10659 Add Configuration::setDefaultMetadataDriverImpl() method for convenience.

📊 Changes

1 file changed (+10 additions, -0 deletions)

View changed files

📝 lib/Doctrine/ORM/Configuration.php (+10 -0)

📄 Description

Current logic to setup Doctrine2 is a bit cluttered, because there's a circular dependency between $config and $driverImpl, which makes it impossible to configure things in Dependency Injection container.

$driverImpl = $config->newDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
$config->setMetadataDriverImpl($driverImpl);
  doctrine.config:
    class: \Doctrine\ORM\Configuration
    calls:
      - [setMetadataCacheImpl, ['@doctrine.metadata_cache']]
      - [setMetadataDriverImpl, ['@doctrine.metadata_driver']]
      ...

Configuration is not fully initialized (and not added to service map) when setMetadataDriverImpl is called, but then setMetadataDriverImpl needs to call Configuration's newDefaultAnnotationDriver. Dependency deadlock.

I think that simpliest way to solve is to introduce setDefaultMetadataDriverImpl() method like this:

$config->setDefaultMetadataDriverImpl('/path/to/lib/MyProject/Entities');
  doctrine.config:
    class: \Doctrine\ORM\Configuration
    calls:
      - [setMetadataCacheImpl, ['@doctrine.metadata_cache']]
      - [setDefaultMetadataDriverImpl, ['/path/to/lib/MyProject/Entities']]
      ...

If you use non-default driver, you need to define everything explicitly anyway.

For default one, now you need to read annotations class and copy logic from newDefaultAnnotationDriver to DI container map on your own.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/238 **Author:** [@sobstel](https://github.com/sobstel) **Created:** 12/23/2011 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`7c10659`](https://github.com/doctrine/orm/commit/7c10659738ff9b8fd3f8c420fb74a4638cafe20d) Add Configuration::setDefaultMetadataDriverImpl() method for convenience. ### 📊 Changes **1 file changed** (+10 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/Configuration.php` (+10 -0) </details> ### 📄 Description Current logic to setup Doctrine2 is a bit cluttered, because there's a circular dependency between $config and $driverImpl, which makes it impossible to configure things in Dependency Injection container. ``` php $driverImpl = $config->newDefaultAnnotationDriver('/path/to/lib/MyProject/Entities'); $config->setMetadataDriverImpl($driverImpl); ``` ``` doctrine.config: class: \Doctrine\ORM\Configuration calls: - [setMetadataCacheImpl, ['@doctrine.metadata_cache']] - [setMetadataDriverImpl, ['@doctrine.metadata_driver']] ... ``` Configuration is not fully initialized (and not added to service map) when setMetadataDriverImpl is called, but then setMetadataDriverImpl needs to call Configuration's newDefaultAnnotationDriver. Dependency deadlock. I think that simpliest way to solve is to introduce setDefaultMetadataDriverImpl() method like this: ``` php $config->setDefaultMetadataDriverImpl('/path/to/lib/MyProject/Entities'); ``` ``` doctrine.config: class: \Doctrine\ORM\Configuration calls: - [setMetadataCacheImpl, ['@doctrine.metadata_cache']] - [setDefaultMetadataDriverImpl, ['/path/to/lib/MyProject/Entities']] ... ``` If you use non-default driver, you need to define everything explicitly anyway. For default one, now you need to read annotations class and copy logic from newDefaultAnnotationDriver to DI container map on your own. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 15:57:28 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7903