Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce DoctrineSetup as a replacement for Setup #9443

Merged
merged 1 commit into from
Jan 30, 2022

Conversation

derrabus
Copy link
Member

The Setup class is a collection of static methods for bootstrapping a ORM configuration with recommended settings. At least that's my understanding of that class. In applications where the ORM is configured through some kind of framework integration (like DoctrineBundle), that class is more or less irrelevant.

The Setup class as of today operates on Doctrine Cache instances. Since the whole ORM is now able to operate on PSR-6 we should do something about it. Unfortunately, since the Setup class is not final, altering all method signatures is quite difficult, so I decided to deprecate the whole class and add a new class named DoctrineSetup as replacement.

Key differences between the two setup classes:

  • The new class is declared final which should make future changes to that class easier.
  • It accepts PSR-6 caches instead of Doctrine Cache instances.
  • If no cache is passed and Symfony Cache is installed, a suitible cache adapter is configured, just like the old class did for Doctrine Cache.
  • The useSimpleAnnotationReader flag is not supported anymore.

Furthermore, I decided to move the newDefaultAnnotationDriver() method from the Configuration class to the new DoctrineSetup class. That method does not really mutate the configuration, it is a simple factory for the annotation driver. DoctrineSetup feels like the better place for it.

@derrabus derrabus added this to the 2.12.0 milestone Jan 30, 2022
@derrabus derrabus force-pushed the deprecate/setup branch 5 times, most recently from e360316 to 5ac2847 Compare January 30, 2022 18:03
/**
* Creates a configuration with a yaml metadata driver.
*
* @deprecated YAML metadata mapping is deprecated and will be removed in 3.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It felt a bit odd to introduce a method and instantly deprecate it. I decided to add the method to allow switching to a PSR-6 cache before migrating the whole YAML mapping configuration to XML or annotations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds me that we should think about deprecating annotations as well… but maybe it's too early?

lib/Doctrine/ORM/Tools/DoctrineSetup.php Outdated Show resolved Hide resolved
/**
* Creates a configuration with a yaml metadata driver.
*
* @deprecated YAML metadata mapping is deprecated and will be removed in 3.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds me that we should think about deprecating annotations as well… but maybe it's too early?

@derrabus derrabus enabled auto-merge (squash) January 30, 2022 22:28
@derrabus derrabus merged commit f81980e into doctrine:2.12.x Jan 30, 2022
derrabus added a commit to derrabus/orm that referenced this pull request Jan 30, 2022
* 2.12.x:
  Introduce DoctrineSetup as a replacement for Setup (doctrine#9443)
  Introduce __unserialize behaviour in docs (doctrine#9390)
  Adapt test logic to PHP and SQLite II (doctrine#9442)
  Use the identify generator strategy
  Added php 8.1 to CI
  Psalm 4.19.0, PHPStan 1.4.3 (doctrine#9438)
  Ignore PHPUnit result cache everywhere (doctrine#9425)
@derrabus derrabus deleted the deprecate/setup branch January 30, 2022 23:04
Copy link
Member

@beberlei beberlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there no uses of Setup in the docs folder?

I am wondering if the name shouldbe ORMSetup and if in the spirit of DriverManager in DBAL we should move it to top lebel.

@derrabus
Copy link
Member Author

Are there no uses of Setup in the docs folder?

I totally forgot about the docs, thanks for the hint. #9448

I am wondering if the name shouldbe ORMSetup and if in the spirit of DriverManager in DBAL we should move it to top lebel.

Yeah, why not. 🤔 I'll look into it tomorrow. 😴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants