As developer, you should probably subclass the PropertyMappingConfiguration class if adjustments are needed there.
 /**
  * Convert the given $source to $targetType depending on the MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE property mapping configuration
  *
  * @param string $source the raw request body
  * @param string $targetType must be "array"
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return array
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
 {
     $mediaType = null;
     if ($configuration !== null) {
         $mediaType = $configuration->getConfigurationValue(MediaTypeConverterInterface::class, MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE);
     }
     if ($mediaType === null) {
         $mediaType = MediaTypeConverterInterface::DEFAULT_MEDIA_TYPE;
     }
     return $this->convertMediaType($source, $mediaType);
 }
 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping).
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
  * - An instance of Error -- This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return mixed|Error the target type, or an error object if a user-error occurred
  * @throws TypeConverterException thrown in case a developer error occurred
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
 {
     $result = [];
     $convertElements = $configuration->getConfigurationValue(ArrayTypeConverter::class, self::CONFIGURATION_CONVERT_ELEMENTS);
     foreach ($source as $element) {
         if ($convertElements === true) {
             $element = $this->propertyMapper->convert($element, 'array', $configuration);
         }
         $result[] = $element;
     }
     return $result;
 }
 /**
  * @test
  */
 public function convertFromSetsRemovedContentShownContextPropertyFromConfigurationForContextPathSource()
 {
     $contextPath = '/foo/bar@user-demo';
     $nodePath = '/foo/bar';
     $mockNode = $this->setUpNodeWithNodeType($nodePath);
     $this->mockConverterConfiguration->expects($this->any())->method('getConfigurationValue')->with(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN)->will($this->returnValue(true));
     $result = $this->nodeConverter->convertFrom($contextPath, null, array(), $this->mockConverterConfiguration);
     $this->assertSame($mockNode, $result);
     $contextProperties = $mockNode->getContext()->getProperties();
     $this->assertArrayHasKey('removedContentShown', $contextProperties, 'removedContentShown context property should be set');
     $this->assertTrue($contextProperties['removedContentShown'], 'removedContentShown context property should be TRUE');
 }
 /**
  * Determines the target type based on the source's (optional) __type key.
  *
  * @param mixed $source
  * @param string $originalTargetType
  * @param PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws InvalidDataTypeException
  * @throws InvalidPropertyMappingConfigurationException
  * @throws \InvalidArgumentException
  */
 public function getTargetTypeForSource($source, $originalTargetType, PropertyMappingConfigurationInterface $configuration = null)
 {
     $targetType = $originalTargetType;
     if (is_array($source) && array_key_exists('__type', $source)) {
         $targetType = $source['__type'];
         if ($configuration === null) {
             throw new \InvalidArgumentException('A property mapping configuration must be given, not NULL.', 1326277369);
         }
         if ($configuration->getConfigurationValue(ObjectConverter::class, self::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED) !== true) {
             throw new InvalidPropertyMappingConfigurationException('Override of target type not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED" to TRUE.', 1317050430);
         }
         if ($targetType !== $originalTargetType && is_a($targetType, $originalTargetType, true) === false) {
             throw new InvalidDataTypeException('The given type "' . $targetType . '" is not a subtype of "' . $originalTargetType . '".', 1317048056);
         }
     }
     return $targetType;
 }
 /**
  * @param PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws InvalidPropertyMappingConfigurationException
  */
 protected function getResourceExportType(PropertyMappingConfigurationInterface $configuration = null)
 {
     if ($configuration === null) {
         return self::DEFAULT_RESOURCE_EXPORT_TYPE;
     }
     $exportType = $configuration->getConfigurationValue(ArrayConverter::class, self::CONFIGURATION_RESOURCE_EXPORT_TYPE);
     if ($exportType === null) {
         return self::DEFAULT_RESOURCE_EXPORT_TYPE;
     } elseif (!is_string($exportType)) {
         throw new InvalidPropertyMappingConfigurationException(sprintf('RESOURCE_EXPORT_TYPE must be of type string, "%s" given', is_object($exportType) ? get_class($exportType) : gettype($exportType)), 1404313373);
     }
     return $exportType;
 }
 /**
  * Handle the case if $source is an array.
  *
  * @param array $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return object|TargetNotFoundError
  * @throws InvalidPropertyMappingConfigurationException
  */
 protected function handleArrayData(array $source, $targetType, array &$convertedChildProperties, PropertyMappingConfigurationInterface $configuration = null)
 {
     if (!isset($source['__identity'])) {
         if ($this->reflectionService->isClassAnnotatedWith($targetType, ValueObject::class) === true) {
             // Allow creation for ValueObjects by default, but prevent if explicitly disallowed
             if ($configuration !== null && $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_CREATION_ALLOWED) === false) {
                 throw new InvalidPropertyMappingConfigurationException('Creation of value objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE');
             }
         } elseif ($configuration === null || $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_CREATION_ALLOWED) !== true) {
             throw new InvalidPropertyMappingConfigurationException('Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE');
         }
         $object = $this->buildObject($convertedChildProperties, $targetType);
     } elseif ($configuration !== null && $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_IDENTITY_CREATION_ALLOWED) === true) {
         $object = $this->fetchObjectFromPersistence($source['__identity'], $targetType);
         if ($object === null) {
             $object = $this->buildObject($convertedChildProperties, $targetType);
             $this->setIdentity($object, $source['__identity']);
         }
     } else {
         $object = $this->fetchObjectFromPersistence($source['__identity'], $targetType);
         if ($object === null) {
             return new TargetNotFoundError(sprintf('Object of type %s with identity "%s" not found.', $targetType, print_r($source['__identity'], true)), 1412283038);
         }
         if (count($convertedChildProperties) > 0 && ($configuration === null || $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_MODIFICATION_ALLOWED) !== true)) {
             throw new InvalidPropertyMappingConfigurationException('Modification of persistent objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_MODIFICATION_ALLOWED" to TRUE.', 1297932028);
         }
     }
     return $object;
 }
 /**
  * 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
  */
 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;
     $sourceTypes = $this->determineSourceTypes($source);
     foreach ($sourceTypes 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 "', $sourceTypes) . '" to "' . $normalizedTargetType . '".');
 }
 /**
  * Determines the default date format to use for the conversion.
  * If no format is specified in the mapping configuration DEFAULT_DATE_FORMAT is used.
  *
  * @param PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws InvalidPropertyMappingConfigurationException
  */
 protected function getDefaultDateFormat(PropertyMappingConfigurationInterface $configuration = null)
 {
     if ($configuration === null) {
         return self::DEFAULT_DATE_FORMAT;
     }
     $dateFormat = $configuration->getConfigurationValue(DateTimeConverter::class, self::CONFIGURATION_DATE_FORMAT);
     if ($dateFormat === null) {
         return self::DEFAULT_DATE_FORMAT;
     } elseif ($dateFormat !== null && !is_string($dateFormat)) {
         throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_DATE_FORMAT must be of type string, "' . (is_object($dateFormat) ? get_class($dateFormat) : gettype($dateFormat)) . '" given', 1307719569);
     }
     return $dateFormat;
 }
 /**
  * @test
  * @dataProvider contentTypesBodiesAndExpectedUnifiedArguments
  */
 public function convertTests($mediaType, $requestBody, array $expectedResult)
 {
     $this->mockPropertyMappingConfiguration->expects($this->atLeastOnce())->method('getConfigurationValue')->with(MediaTypeConverterInterface::class, MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE)->will($this->returnValue($mediaType));
     $actualResult = $this->mediaTypeConverter->convertFrom($requestBody, 'array', [], $this->mockPropertyMappingConfiguration);
     $this->assertSame($expectedResult, $actualResult);
 }
 /**
  * Helper method to collect configuration for this class.
  *
  * @param PropertyMappingConfigurationInterface $configuration
  * @param array $configurationKeys
  * @return array
  */
 protected function getConfigurationKeysAndValues(PropertyMappingConfigurationInterface $configuration, array $configurationKeys)
 {
     $keysAndValues = [];
     foreach ($configurationKeys as $configurationKey) {
         $keysAndValues[$configurationKey] = $configuration->getConfigurationValue(FloatConverter::class, $configurationKey);
     }
     return $keysAndValues;
 }
 /**
  * Get the collection name this resource will be stored in. Default will be ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME
  * The propertyMappingConfiguration CONFIGURATION_COLLECTION_NAME will directly override the default. Then if CONFIGURATION_ALLOW_COLLECTION_OVERRIDE is TRUE
  * and __collectionName is in the $source this will finally be the value.
  *
  * @param array $source
  * @param PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws InvalidPropertyMappingConfigurationException
  */
 protected function getCollectionName($source, PropertyMappingConfigurationInterface $configuration = null)
 {
     if ($configuration === null) {
         return ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
     }
     $collectionName = $configuration->getConfigurationValue(ResourceTypeConverter::class, self::CONFIGURATION_COLLECTION_NAME) ?: ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
     if (isset($source['__collectionName']) && $source['__collectionName'] !== '') {
         $collectionName = $source['__collectionName'];
     }
     if ($this->resourceManager->getCollection($collectionName) === null) {
         throw new InvalidPropertyMappingConfigurationException(sprintf('The selected resource collection named "%s" does not exist, a resource could not be imported.', $collectionName), 1416687475);
     }
     return $collectionName;
 }
 /**
  * Determines the format to use for the conversion from array to string.
  *
  * If no format is specified in the mapping configuration DEFAULT_ARRAY_FORMAT is used.
  *
  * @param PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws InvalidPropertyMappingConfigurationException
  */
 protected function getArrayFormat(PropertyMappingConfigurationInterface $configuration = null)
 {
     if ($configuration === null) {
         return self::DEFAULT_ARRAY_FORMAT;
     }
     $arrayFormat = $configuration->getConfigurationValue(StringConverter::class, self::CONFIGURATION_ARRAY_FORMAT);
     if ($arrayFormat === null) {
         return self::DEFAULT_ARRAY_FORMAT;
     } elseif (!is_string($arrayFormat)) {
         throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_ARRAY_FORMAT must be of type string, "' . (is_object($arrayFormat) ? get_class($arrayFormat) : gettype($arrayFormat)) . '" given', 1404228995);
     }
     return $arrayFormat;
 }
 /**
  * Prepares the context properties for the nodes based on the given workspace and dimensions
  *
  * @param string $workspaceName
  * @param PropertyMappingConfigurationInterface $configuration
  * @param array $dimensions
  * @return array
  */
 protected function prepareContextProperties($workspaceName, PropertyMappingConfigurationInterface $configuration = null, array $dimensions = null)
 {
     $contextProperties = array('workspaceName' => $workspaceName, 'invisibleContentShown' => false, 'removedContentShown' => false);
     if ($workspaceName !== 'live') {
         $contextProperties['invisibleContentShown'] = true;
         if ($configuration !== null && $configuration->getConfigurationValue(\Neos\ContentRepository\TypeConverter\NodeConverter::class, self::REMOVED_CONTENT_SHOWN) === true) {
             $contextProperties['removedContentShown'] = true;
         }
     }
     if ($dimensions !== null) {
         $contextProperties['dimensions'] = $dimensions;
     }
     return $contextProperties;
 }
 /**
  * Convert an object from $source to an \Neos\Media\Domain\Model\AssetInterface implementation
  *
  * @param mixed $source
  * @param string $targetType must implement 'Neos\Media\Domain\Model\AssetInterface'
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return Error|AssetInterface The converted Asset, a Validation Error or NULL
  * @throws InvalidTargetException
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null)
 {
     $object = null;
     if (is_string($source) && $source !== '') {
         $source = array('__identity' => $source);
     }
     if (isset($convertedChildProperties['resource']) && $convertedChildProperties['resource'] instanceof PersistentResource) {
         $resource = $convertedChildProperties['resource'];
         if (isset($this->resourcesAlreadyConvertedToAssets[$resource->getSha1()])) {
             $object = $this->resourcesAlreadyConvertedToAssets[$resource->getSha1()];
         }
         // This is pretty late to override the targetType, but usually you want to determine the model type from the resource when a new resource was uploaded...
         $targetType = $this->applyModelMappingStrategy($targetType, $resource, $source);
     }
     if ($object === null) {
         if ($configuration !== null && $configuration->getConfigurationValue(self::class, self::CONFIGURATION_ONE_PER_RESOURCE) === true && isset($convertedChildProperties['resource'])) {
             $resource = $convertedChildProperties['resource'];
             $possibleAsset = $this->assetRepository->findOneByResourceSha1($resource->getSha1());
             if ($possibleAsset !== null) {
                 $this->resourceManager->deleteResource($resource);
                 return $possibleAsset;
             }
         }
         $object = parent::convertFrom($source, $targetType, $convertedChildProperties, $configuration);
     }
     if ($object instanceof AssetInterface) {
         $object = $this->applyTypeSpecificHandling($object, $source, $convertedChildProperties, $configuration);
         if ($object !== null) {
             $this->resourcesAlreadyConvertedToAssets[$object->getResource()->getSha1()] = $object;
             if (isset($resource) && $resource !== $object->getResource()) {
                 $this->resourceManager->deleteResource($resource);
             }
         }
     }
     return $object;
 }