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

Enable @CustomIdGenerator() to reference services tagged as "doctrine.id_generator" #1284

Merged
merged 1 commit into from
Feb 15, 2021

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jan 28, 2021

Fixes #759

This PR enables referencing services when using the @CustomIdGenerator() annotation.

It works by creating a service locator of all services tagged as doctrine.id_generator, and checking that locator when a custom id generator is found. Usage:

/**
 * @ORM\GeneratedValue(strategy="CUSTOM")
 * @ORM\CustomIdGenerator('doctrine.uuid_generator')
 */

@ostrolucky
Copy link
Member

You are changing this a lot. We will review after you are done. We will also need tests in the end. But feature is welcome.

fabpot added a commit to symfony/symfony that referenced this pull request Jan 28, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
… Uid generators (nicolas-grekas)

This PR was merged into the 5.2 branch.

Discussion
----------

[DoctrineBridge] add missing `@experimental` annotation on Uid generators

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Forgotten when we created the classes.

Needed since I plan to remove all the `UuidV*` generators. They're useless and a more flexible approach based on doctrine/DoctrineBundle#1284 is coming.

Commits
-------

e380102 [DoctrineBridge] add missing `@experimental` annotation on Uid generators
@nicolas-grekas
Copy link
Member Author

I was fighting the CS checker ;)
Should be good for a first round!

@nicolas-grekas nicolas-grekas force-pushed the service-id-generator branch 4 times, most recently from aa46925 to e61237e Compare January 29, 2021 11:11
@nicolas-grekas nicolas-grekas requested a review from stof January 29, 2021 11:11
@nicolas-grekas nicolas-grekas force-pushed the service-id-generator branch 2 times, most recently from 12a4f5a to c8caaf5 Compare January 29, 2021 15:11
@nicolas-grekas
Copy link
Member Author

PR is now tested and ready for review.

@nicolas-grekas nicolas-grekas removed the request for review from weaverryan January 29, 2021 15:23
@nicolas-grekas nicolas-grekas force-pushed the service-id-generator branch 2 times, most recently from 3f58beb to a2f59c8 Compare January 29, 2021 15:33
Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

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

So far looks like a can of worms to me without having doctrine/orm#7134

@nicolas-grekas nicolas-grekas force-pushed the service-id-generator branch 2 times, most recently from 8f92b94 to dc74aba Compare January 30, 2021 15:49
@nicolas-grekas
Copy link
Member Author

Thanks for the review @ostrolucky. I fixed the most technical comments. I'll let you know when I'm done with the remaining ones.

@nicolas-grekas nicolas-grekas force-pushed the service-id-generator branch 3 times, most recently from a51ee30 to 8385e1c Compare February 1, 2021 10:40
@nicolas-grekas
Copy link
Member Author

Now with a doc page. Ready for another review.

<service id="doctrine.uuid_generator" class="Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator" public="false">
<argument type="service" id="uuid.factory" on-invalid="ignore" />
<tag name="doctrine.id_generator" />
</service>
Copy link
Member Author

Choose a reason for hiding this comment

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

added back now that symfony/symfony#39507 is merged

@ostrolucky ostrolucky self-requested a review February 12, 2021 09:09
Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

This is a great addition that makes working with ID generators in Symfony so much easier, thank you very much @nicolas-grekas!

I've left some comments, but in general this LGTM!

@nicolas-grekas nicolas-grekas force-pushed the service-id-generator branch 4 times, most recently from cef1b6c to e174049 Compare February 12, 2021 10:08
@nicolas-grekas
Copy link
Member Author

Am I allowed to merge now that the two of you approved the PR?

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

Successfully merging this pull request may close these issues.

None yet

4 participants