Reputation: 1066
I have 2 Entities City and Region
City linked to Region this way:
/**
* @ORM\ManyToOne(targetEntity="Region", inversedBy="cities")
* @var Region
*/
protected $region;
How can I get Region class name having only "region" string (and knowing that region is a relation of City
)?
Upvotes: 0
Views: 699
Reputation: 54659
On the entity/object manager (\Doctrine\Common\Persistence\ObjectManager
) you can call getClassMetadata($className)
.
E.g.:
$metaData = $em->getClassMetadata(City::class);
$metaData->getAssociationTargetClass('region'); // => 'Region'
Upvotes: 1