Doctrine\OXM\Mapping\ClassMetadata::getFieldValue PHP Méthode

getFieldValue() public méthode

Gets the specified field's value off the given entity.
public getFieldValue ( object $entity, string $fieldName )
$entity object
$fieldName string
    public function getFieldValue($entity, $fieldName)
    {
        if ($this->fieldMappings[$fieldName]['direct']) {
            return $this->reflFields[$fieldName]->getValue($entity);
        } else {
            if (!array_key_exists('getMethod', $this->fieldMappings[$fieldName])) {
                $this->fieldMappings[$fieldName]['getMethod'] = $this->inferGetter($fieldName);
            }
            $getter = $this->fieldMappings[$fieldName]['getMethod'];
            if ($this->reflClass->hasMethod($getter)) {
                return call_user_func(array($entity, $getter));
            } else {
                throw MappingException::fieldGetMethodDoesNotExist($this->name, $fieldName, $getter);
            }
        }
    }