kkreft
4/21/2017 - 2:55 PM

using Doctrine Reflections to find getter for specific fieldName

using Doctrine Reflections to find getter for specific fieldName

$fieldName = 'city';

$repository = $this->em->getRepository(get_class($obj));
$metaClass = $this->em->getClassMetadata(get_class($obj));

if (!$metaClass->hasField($fieldName) && !$metacClass->hasAssociation($fieldName)) {
    return;
}

$value = $metaClass->reflFields[$fieldName]->getValue($obj);