8000 [WIP] [DoctrineBridge] Refactor EntityChoiceList by beberlei · Pull Request #2728 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WIP] [DoctrineBridge] Refactor EntityChoiceList #2728

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

Closed
wants to merge 7 commits into from

Conversation

beberlei
Copy link
Contributor

Bug fix: no
Feature addition: yes
Backwards compatibility break: no (99%)
Symfony2 tests pass: yes

This decouples the ORM from the EntityChoiceList and makes its much more flexible. Instead of having a "query_builder" to do smart or complex queries you can now create "loader" instances which can arbitrarily help loading entities.

Additionally i removed lots of code that was unnecessary and not used by the current code.

There is a slight BC break in that the EntityChoiceList class is now accepting an EntityLoaderInterface instead of a querybuilder. However that class was nested inside the EntityType and should not be widely used or overwritten.

$this->unitOfWork = $em->getUnitOfWork();
$this->identifier = $em->getClassMetadata($class)->getIdentifierFieldNames();
$this->entityLoader = $entityLoader;
$this->unitOfWork = $manager->getUnitOfWork();
Copy link
Member

Choose a reason for hiding this comment

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

this is not part of the interface. Nothing enforces have a UnitOfWork when implementing the interface

@stof
Copy link
Member
stof commented Dec 12, 2011

@beberlei can 8000 you rebase this PR and update it ?

@stof
Copy link
Member
stof commented Dec 12, 2011

If you cannot, I can continue it. This refactoring is needed IMO


public function __toString()
{
return (string)$this->name;
Copy link
Member

Choose a reason for hiding this comment

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

according to the CS, you need to add a space here after the cast

@fabpot
Copy link
Member
fabpot commented Dec 19, 2011

What's the status of this PR?

@stof
Copy link
Member
stof commented Dec 19, 2011

@fabpot I just sent a Pr to @beberlei to implement my suggestion: beberlei#1

As this PR needs to be rebased to fix conflicts, either @beberlei does it after merging the PR in his repo, either I rebase my branch and open a new PR to the symfony repo directly depending if he wants to do the work or if he prefers letting me doing it.

@stof
Copy link
Member
stof commented Dec 19, 2011

completed and rebased in #2921 so closing this one

@stof stof closed this Dec 19, 2011
fabpot added a commit that referenced this pull request Dec 19, 2011
Commits
-------

200ed54 [DoctrineBridge] Extracted the common type and made the choice list generic
3c81b62 [Doctrine] Cleanup and move loader into its own method
7646a5b [Doctrine] Dont allow null in ORMQueryBuilderLoader
988c2a5 Adjust check
3b5c617 [DoctrineBridge] Remove large parts of the EntityChoiceList code that were completly unnecessary (code was unreachable).
b919d92 [DoctrineBridge] Optimize fetching of entities to use WHERE IN and fix other inefficencies.
517eebc [DoctrineBridge] Refactor entity choice list to be ORM independant using an EntityLoader interface.

Discussion
----------

[DoctrineBridge] Refactor EntityChoiceList

Bug fix: no
Feature addition: yes
Backwards compatibility break: no (99%)
Symfony2 tests pass: yes

This decouples the ORM from the EntityChoiceList and makes its much more flexible. Instead of having a "query_builder" to do smart or complex queries you can now create "loader" instances which can arbitrarily help loading entities.

Additionally i removed lots of code that was unnecessary and not used by the current code.

There is a slight BC break in that the EntityChoiceList class is now accepting an EntityLoaderInterface instead of a querybuilder. However that class was nested inside the EntityType and should not be widely used or overwritten.

The abstract class DoctrineType is meant to be used as base class by other Doctrine project to share the logic by simply using a different type name and a different loader implementation.

This PR replaces #2728.

---------------------------------------------------------------------------

by beberlei at 2011/12/19 09:20:43 -0800

Thanks for doing the last refactorings, this is now fine from my side as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0