Set a type converter which should be used for this specific conversion.
public setTypeConverter ( Neos\Flow\Property\TypeConverterInterface $typeConverter ) : |
||
$typeConverter | Neos\Flow\Property\TypeConverterInterface | |
return | this |
/** * Parses the request body according to the media type. * * @param HttpRequest $httpRequest * @return array */ protected function parseRequestBody(HttpRequest $httpRequest) { $requestBody = $httpRequest->getContent(); if ($requestBody === null || $requestBody === '') { return []; } $mediaTypeConverter = $this->objectManager->get(MediaTypeConverterInterface::class); $propertyMappingConfiguration = new PropertyMappingConfiguration(); $propertyMappingConfiguration->setTypeConverter($mediaTypeConverter); $propertyMappingConfiguration->setTypeConverterOption(MediaTypeConverterInterface::class, MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE, $httpRequest->getHeader('Content-Type')); $arguments = $this->propertyMapper->convert($requestBody, 'array', $propertyMappingConfiguration); return $arguments; }
/** * @test */ public function getTypeConverterReturnsTypeConverterIfItHasBeenSet() { $mockTypeConverter = $this->createMock(TypeConverterInterface::class); $this->propertyMappingConfiguration->setTypeConverter($mockTypeConverter); $this->assertSame($mockTypeConverter, $this->propertyMappingConfiguration->getTypeConverter()); }
/** * @param PropertyMappingConfiguration $propertyMappingConfiguration * @param string $dataType * @return boolean */ protected function setTypeConverterForType(PropertyMappingConfiguration $propertyMappingConfiguration, $dataType) { if (!isset($this->typesConfiguration[$dataType]) || !isset($this->typesConfiguration[$dataType]['typeConverter'])) { return false; } $typeConverter = $this->objectManager->get($this->typesConfiguration[$dataType]['typeConverter']); $propertyMappingConfiguration->setTypeConverter($typeConverter); $this->setTypeConverterOptionsForType($propertyMappingConfiguration, $this->typesConfiguration[$dataType]['typeConverter'], $dataType); return true; }