Doctrine get all field names with associations

doctrine, doctrine-orm, php, symfony

Solution

You can get the associated field names as well then merge them

$properties = $em->getClassMetadata('YourBundle:Product')->getFieldNames();
$output = array_merge(
              $properties, 
              $em->getClassMetadata('YourBundle:Product')->getAssociationNames()
);

Problem

I already know how to get field names for entity, but how to get class names for all associations also? ``` $em->getClassMetadata('Product')->getFieldNames(); ``` This gets class property only, but I expect to get association names inside nested array, for example if I have customer associated to product I would like to get all customer class property names too.

Original source