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

DefaultRepositoryFactory: single repository for aliased entities #1112

Merged

Conversation

giosh94mhz
Copy link
Contributor

The actual implementation of DefaultRepositoryFactory create multiple instances for a single entity if is accessed by multiple namespace aliases.

I've patched DefaultRepositoryFactory::getRepository so that aliases are resolved before saving the reference into the repositoryList.

Just to not affect performance of existing implementation, I've added to the repositoryList both the aliased class name and the fully-qualified class name, but only the latter is required.

$this->repositoryList[$class] = $repository;

if ($class !== $entityName) {
$this->repositoryList[$entityName] = &$this->repositoryList[$class];
Copy link
Member

Choose a reason for hiding this comment

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

no need to assign it by reference. It is an object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've entered paranoid-mode :) fixed it!

@giosh94mhz
Copy link
Contributor Author

@stof maybe you mean line 50? I've left the original $entityName an not $class since the method is protected and may be considered a BC change. By changing this, all subclass which rely on aliases will no longer work. IMO, $class must be used, since it never change.

@giosh94mhz
Copy link
Contributor Author

Ok, @Ocramius . I've updated the commit.

@Ocramius Ocramius self-assigned this Aug 18, 2014
@Ocramius
Copy link
Member

@giosh94mhz checking out locally and merging, thanks!

@Ocramius Ocramius merged commit a665cb0 into doctrine:master Aug 18, 2014
Ocramius added a commit that referenced this pull request Aug 18, 2014
Ocramius added a commit that referenced this pull request Aug 18, 2014
Ocramius added a commit that referenced this pull request Aug 18, 2014
Ocramius added a commit that referenced this pull request Aug 18, 2014
@giosh94mhz giosh94mhz deleted the single_repository_for_aliased_entity branch August 18, 2014 13:26
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