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

Added function to return identifiers from proxy #415

Closed

Conversation

baldurrensch
Copy link

I needed a way to get the identfiers of a doctrine proxy immediately without going through the unit of work (not available)
or without actually waking up the entity. The proxy already has that information, I just added a public
getter.

I needed a way to get the identfiers of a doctrine proxy immediately without going through the unit of work
or without actually waking uo the identity. The proxy already has that information, I just added a public
getter.
@travisbot
Copy link

This pull request passes (merged fcd86b3 into 00a5f18).

@stof
Copy link
Member

stof commented Jul 30, 2012

I don't see the need for it. Simply call your regular getter for the id. As of Doctrine 2.2, it should not initialize the proxy anymore (except if you add some fancy logic in the getter, as the ProxyFactory checks whether the method looks like a simple getter)

@stof
Copy link
Member

stof commented Jul 30, 2012

And this is a wrong implementation btw: the method would return null when the proxy is initialized as the property is unset.

@baldurrensch
Copy link
Author

@stof: You are right, that you can simply call the getter of the id columns, but you need to know what those are for a given entity. I am in a situation where I will get some proxy object. Of course, I could now use the class metadata to get the names of the id columns. That seems overly complex. Is there a better way to accomplish this?

@stof
Copy link
Member

stof commented Jul 30, 2012

well, compared to a solution which is broken by design, I think it is better.

@beberlei
Copy link
Member

If you dont know the real class use the metadata, or give them all the same id field name.

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.

4 participants