protected function findTypeConverter($source, $targetType, PropertyMappingConfigurationInterface $configuration)
    {
        if ($configuration->getTypeConverter() !== null) {
            return $configuration->getTypeConverter();
        }

        if (!is_string($targetType)) {
            throw new Exception\InvalidTargetException('The target type was no string, but of type "' . gettype($targetType) . '"', 1297941727);
        }
        $normalizedTargetType = TypeHandling::normalizeType($targetType);
        $truncatedTargetType = TypeHandling::truncateElementType($normalizedTargetType);
        $converter = null;

        $normalizedSourceTypes = $this->determineSourceTypes($source);
        foreach ($normalizedSourceTypes as $sourceType) {
            if (TypeHandling::isSimpleType($truncatedTargetType)) {
                if (isset($this->typeConverters[$sourceType][$truncatedTargetType])) {
                    $converter = $this->findEligibleConverterWithHighestPriority($this->typeConverters[$sourceType][$truncatedTargetType], $source, $normalizedTargetType);
                }
            } else {
                $converter = $this->findFirstEligibleTypeConverterInObjectHierarchy($source, $sourceType, $normalizedTargetType);
            }

            if ($converter !== null) {
                return $converter;
            }
        }

        throw new Exception\TypeConverterException('No converter found which can be used to convert from "' . implode('" or "', $normalizedSourceTypes) . '" to "' . $normalizedTargetType . '".');
    }
protected function findTypeConverter($source, $targetType, PropertyMappingConfigurationInterface $configuration)
    {
        if ($configuration->getTypeConverter() !== null) {
            return $configuration->getTypeConverter();
        }

        if (!is_string($targetType)) {
            throw new Exception\InvalidTargetException('The target type was no string, but of type "' . gettype($targetType) . '"', 1297941727);
        }
        $normalizedTargetType = TypeHandling::normalizeType($targetType);
        $truncatedTargetType = TypeHandling::truncateElementType($normalizedTargetType);
        $converter = null;

        $normalizedSourceTypes = $this->determineSourceTypes($source);
        foreach ($normalizedSourceTypes as $sourceType) {
            if (TypeHandling::isSimpleType($truncatedTargetType)) {
                if (isset($this->typeConverters[$sourceType][$truncatedTargetType])) {
                    $converter = $this->findEligibleConverterWithHighestPriority($this->typeConverters[$sourceType][$truncatedTargetType], $source, $normalizedTargetType);
                }
            } else {
                $converter = $this->findFirstEligibleTypeConverterInObjectHierarchy($source, $sourceType, $normalizedTargetType);
            }

            if ($converter !== null) {
                return $converter;
            }
        }

        throw new Exception\TypeConverterException('No converter found which can be used to convert from "' . implode('" or "', $normalizedSourceTypes) . '" to "' . $normalizedTargetType . '".');
    }
protected function findTypeConverter ( $ source , $ targetType , PropertyMappingConfigurationInterface $ configuration ) { if ( $ configuration -> getTypeConverter ( ) !== null ) { return $ configuration -> getTypeConverter ( ) ; } if ( ! is_string ( $ targetType ) ) { throw new Exception \ InvalidTargetException ( 'The target type was no string, but of type "' . gettype ( $ targetType ) . '"' , 1297941727 ) ; } $ normalizedTargetType = TypeHandling :: normalizeType ( $ targetType ) ; $ truncatedTargetType = TypeHandling :: truncateElementType ( $ normalizedTargetType ) ; $ converter = null ; $ normalizedSourceTypes = $ this -> determineSourceTypes ( $ source ) ; foreach ( $ normalizedSourceTypes as $ sourceType ) { if ( TypeHandling :: isSimpleType ( $ truncatedTargetType ) ) { if ( isset ( $ this -> typeConverters [ $ sourceType ] [ $ truncatedTargetType ] ) ) { $ converter = $ this -> findEligibleConverterWithHighestPriority ( $ this -> typeConverters [ $ sourceType ] [ $ truncatedTargetType ] , $ source , $ normalizedTargetType ) ; } } else { $ converter = $ this -> findFirstEligibleTypeConverterInObjectHierarchy ( $ source , $ sourceType , $ normalizedTargetType ) ; } if ( $ converter !== null ) { return $ converter ; } } throw new Exception \ TypeConverterException ( 'No converter found which can be used to convert from "' . implode ( '" or "' , $ normalizedSourceTypes ) . '" to "' . $ normalizedTargetType . '".' ) ; }
Determine the type converter to be used. If no converter has been found, an exception is raised.

@param mixed $source
@param string $targetType
@param PropertyMappingConfigurationInterface $configuration
@return TypeConverterInterface Type Converter which should be used to convert between $source and $targetType.
@throws Exception\TypeConverterException
@throws Exception\InvalidTargetException
Determine the type converter to be used . If no converter has been found an exception is raised .