I have 2 entities: Country (id, name) and Mapping (id, object, internalId, externalId). Country and Mapping are not connected with associations (because Mapping has rows not only for country). I need to get external id for country using following conditions:
- country.id = mapping.internalId
- mapping.object = 'country'
So I plan to add function getExternalId() in Country
function getExternalId() {
    $em = Registry::getEntityManager();
    $mapping = $em->getRepository('Mapping')->findOneBy(array(
        'object'     => 'country',
        'internalId' => $this->getId()
    ));
    return !empty($mapping) ? $mapping->getExternalId() : false;
}
Questions:
- Is it good practice to use EntityManager inside entities? If no, please explain how to get external id in my case?
- Maybe it is possible to associate Country and Mapping using yaml files?
Thanks in advance!
 
     
     
     
     
     
     
    