This function will fetch the type converter which will convert the source
to the requested target type.

@param mixed $source
@param mixed $targetType
@param mixed $configuration
@return TypeConverterInterface
@throws TypeConverterException
512563
protected function getTypeConverter($source, $targetType, $configuration)
    {
        $compositeType = $this->parseCompositeType($targetType);

        if (in_array($compositeType, ['\\ArrayObject', 'array'])) {
            $typeConverter = $this->objectManager->get(ArrayConverter::class);
        } else {
            $typeConverter = $this->findTypeConverter($source, $targetType, $configuration);

            if ($typeConverter instanceof ExtbaseArrayConverter) {
                $typeConverter = $this->objectManager->get(ArrayConverter::class);
            } elseif ($typeConverter instanceof ObjectConverter) {
                $typeConverter = $this->getObjectConverter();
            }
        }

        if (!is_object($typeConverter) || !$typeConverter instanceof TypeConverterInterface) {
            throw new TypeConverterException('Type converter for "' . $source . '" -> "' . $targetType . '" not found.');
        }

        return $typeConverter;
    }
314139
public static <E, T> List<E> convert(List<T> source, Class<E> targetClass) {
        return BeansConvertStrategy.convertBeans(source, targetClass, false);
    }
1313349
public static <T> T convert(Object source, TypeReference<T> destType) {
        return JSON.convertValue(source, destType);
    }
908665
protected function doMapping($source, $targetType, PropertyMappingConfigurationInterface $configuration, &$currentPropertyPath)
    {
        if ($source === null) {
            return null;
        }

        $typeConverter = $this->getTypeConverter($source, $targetType, $configuration);
        $targetType = ltrim($typeConverter->getTargetTypeForSource($source, $targetType), '\\');

        if (Core::get()->classExists($targetType)) {
            $targetType = $this->handleMixedType($source, $targetType, $currentPropertyPath);
            $source = $this->handleDataPreProcessor($source, $targetType, $currentPropertyPath);

            if (MixedTypesResolver::OBJECT_TYPE_NONE === $targetType) {
                return null;
            }
        }

        $convertedChildProperties = (is_array($source))
            ? $this->convertChildProperties($source, $targetType, $typeConverter, $configuration, $currentPropertyPath)
            : [];

        $this->configurationObjectConversionDTO
            ->setSource($source)
            ->setTargetType($targetType)
            ->setConvertedChildProperties($convertedChildProperties)
            ->setCurrentPropertyPath($currentPropertyPath)
            ->setResult(null);
        $this->serviceFactory->runServicesFromEvent(ObjectConversionBeforeServiceEventInterface::class, 'objectConversionBefore', $this->configurationObjectConversionDTO);

        if (null === $this->configurationObjectConversionDTO->getResult()) {
            $result = $typeConverter->convertFrom($source, $targetType, $convertedChildProperties);
            $this->configurationObjectConversionDTO->setResult($result);
        }

        $this->serviceFactory->runServicesFromEvent(ObjectConversionAfterServiceEventInterface::class, 'objectConversionAfter', $this->configurationObjectConversionDTO);
        $result = $this->configurationObjectConversionDTO->getResult();

        if ($result instanceof Error) {
            $this->messages
                ->forProperty(implode('.', $currentPropertyPath))
                ->addError($result);
        }

        return $result;
    }
1030548
public <T> T convert(Object source, TypeReference<T> typeReference)
			throws ConverterException {
		return (T) convert(new ConversionContext(), source, typeReference);
	}
135702
public static <TARGET> CopyingConverter<Object, TARGET> forTargetType(final Class<TARGET> target) {
        final Typed<TARGET> targetType = TypeUtils.wrap(target);

        return new Fluent<TARGET>(requireDefaultConstructor(target)) {
            @Override
            public Typed<TARGET> getTargetType() {
                return targetType;
            }
        };
    }
71731
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $specificTargetType = $this->objectContainer->getImplementationClassName($targetType);

        if (Core::get()->classExists($specificTargetType)) {
            $propertyTags = $this->reflectionService->getPropertyTagValues($specificTargetType, $propertyName, 'var');

            if (!empty($propertyTags)) {
                return current($propertyTags);
            }
        }

        return parent::getTypeOfChildProperty($targetType, $propertyName, $configuration);
    }
1042609
public function add(SourceTypeInterface $type, $alias)
    {
        if ($alias !== $type->getName()) {
            throw new SourceTypeException(sprintf('Mapper source type %s alias is not valid!', $alias));
        }

        $this->types[$alias] = $type;
    }
394682
public <T> T convert(ConversionContext context, Object source,
			TypeReference<T> destinationType) throws ConverterException {
		try {
			return (T) multiConverter.convert(context, source, destinationType);
		} catch (ConverterException e) {
			throw e;
		} catch (Exception e) {
			// There is a problem with one converter. This should not happen.
			// Either there is a bug in this converter or it is not properly
			// configured
			throw new ConverterException(
					MessageFormat
							.format(
									"Could not convert given object with class ''{0}'' to object with type signature ''{1}''",
									source == null ? "null" : source.getClass()
											.getName(), destinationType), e);
		}
	}
1162143
protected function extractNodeType($targetType, array $source)
    {
        if (isset($source['__nodeType'])) {
            $nodeTypeName = $source['__nodeType'];
        } else {
            $matches = [];
            preg_match(self::EXTRACT_CONTENT_TYPE_PATTERN, $targetType, $matches);
            if (isset($matches['nodeType'])) {
                $nodeTypeName = $matches['nodeType'];
            } else {
                $nodeTypeName = 'unstructured';
            }
        }
        return $this->nodeTypeManager->getNodeType($nodeTypeName);
    }
915322
public function canConvertFrom($source, $targetType)
    {
        if (is_array($source)) {
            if (isset($source['dateMask']) && ($source['dateMask'] !== '') && isset($source['date'])) {
                if ($source['dateMask'] === $source['date']) {
                    return true;
                }
            }
            return false;
        }
    }
254703
public function canConvertFrom($source, $targetType)
    {
        if (!is_subclass_of($targetType, $this->targetType)) {
            return false;
        }
        if (is_array($source) && !isset($source['__identity'])) {
            return false;
        }
        return true;
    }
634125
@SuppressWarnings("unchecked")
  public <T extends R> Converter<S, T> getConverter(Class<T> targetType) {
    return (Converter<S, T>) converters.get(targetType);
  }
325943
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(ObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
        if ($configuredTargetType !== null) {
            return $configuredTargetType;
        }

        $methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');
        if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) {
            return $methodParameters[$propertyName]['type'];
        } elseif ($this->reflectionService->hasMethod($targetType, ObjectAccess::buildSetterMethodName($propertyName))) {
            $methodParameters = $this->reflectionService->getMethodParameters($targetType, ObjectAccess::buildSetterMethodName($propertyName));
            $methodParameter = current($methodParameters);
            if (!isset($methodParameter['type'])) {
                throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
            } else {
                return $methodParameter['type'];
            }
        } else {
            $targetPropertyNames = $this->reflectionService->getClassPropertyNames($targetType);
            if (in_array($propertyName, $targetPropertyNames)) {
                $varTagValues = $this->reflectionService->getPropertyTagValues($targetType, $propertyName, 'var');
                if (count($varTagValues) > 0) {
                    // This ensures that FQCNs are returned without leading backslashes. Otherwise, something like @var \DateTime
                    // would not find a property mapper. It is needed because the ObjectConverter doesn't use class schemata,
                    // but reads the annotations directly.
                    $declaredType = strtok(trim(current($varTagValues), " \n\t"), " \n\t");
                    try {
                        $parsedType = TypeHandling::parseType($declaredType);
                    } catch (InvalidTypeException $exception) {
                        throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $targetType . '" for property "' . $propertyName . '"'), 1467699674);
                    }
                    return $parsedType['type'] . ($parsedType['elementType'] !== null ? '<' . $parsedType['elementType'] . '>' : '');
                } else {
                    throw new InvalidTargetException(sprintf('Public property "%s" had no proper type annotation (i.e. "@var") in target object of type "%s".', $propertyName, $targetType), 1406821818);
                }
            }
        }

        if ($configuration->shouldSkipUnknownProperties() || $configuration->shouldSkip($propertyName)) {
            return null;
        }

        throw new InvalidTargetException(sprintf('Property "%s" has neither a setter or constructor argument, nor is public, in target object of type "%s".', $propertyName, $targetType), 1303379126);
    }
130428
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        switch ($propertyName) {
            case 'resource':
                return PersistentResource::class;
            case 'originalAsset':
                return Image::class;
            case 'title':
                return 'string';
        }
        return parent::getTypeOfChildProperty($targetType, $propertyName, $configuration);
    }
892353
protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
    {
        $processor = new Processor();

        return $processor->processConfiguration($configuration, $configs);
    }
502587
protected function getDataFromRequest(Request $request, $configuration = null)
    {
        if (null === $configuration) {
            $configuration = [
                new ParamConverter(
                    [
                        'name' => 'data',
                        'class' => $this->admin->getEntity(),
                    ]
                ),
            ];
        }
        $this->container->get('sensio_framework_extra.converter.manager')->apply($request, $configuration);

        return $request->attributes->get('data');
    }