koral
koral

Reputation: 2945

Symfony and Doctrine2 - get info from annotations

I have entity User with field userName (with appriopriate getter and setter) which maps to field user_name in table users. In UserRepository I fetch one record from database and I have $user of class User. How can I find out table and field name for $user->userName ? I need somehow to fetch information from annotations. I found that this information is in Doctrine2 cache and I found class ClassMetadataInfo documentation but I don't know how to put it together.

Upvotes: 1

Views: 1556

Answers (1)

AdrienBrault
AdrienBrault

Reputation: 7745

You should be able to get the class metadata of a specific class by doing so:

$entityManager->getClassMetadata(get_class($user))

Upvotes: 5

Related Questions