/** * @test */ public function setTypeConverterOptionShouldOverrideAlreadySetOptions() { $this->propertyMappingConfiguration->setTypeConverterOptions('someConverter', array('k1' => 'v1', 'k2' => 'v2')); $this->propertyMappingConfiguration->setTypeConverterOption('someConverter', 'k1', 'v3'); $this->assertEquals('v3', $this->propertyMappingConfiguration->getConfigurationValue('someConverter', 'k1')); $this->assertEquals('v2', $this->propertyMappingConfiguration->getConfigurationValue('someConverter', 'k2')); }
/** * Modify the passed $propertyMappingConfiguration according to the $propertyConfiguration which * has been generated by Fluid. In detail, if the $propertyConfiguration contains * an __identity field, we allow modification of objects; else we allow creation. * * All other properties are specified as allowed properties. * * @param array $propertyConfiguration * @param \TYPO3\FLOW3\Property\PropertyMappingConfiguration $propertyMappingConfiguration * @return void */ protected function modifyPropertyMappingConfiguration($propertyConfiguration, \TYPO3\FLOW3\Property\PropertyMappingConfiguration $propertyMappingConfiguration) { if (!is_array($propertyConfiguration)) { return; } if (isset($propertyConfiguration['__identity'])) { $propertyMappingConfiguration->setTypeConverterOption('TYPO3\\FLOW3\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, TRUE); unset($propertyConfiguration['__identity']); } else { $propertyMappingConfiguration->setTypeConverterOption('TYPO3\\FLOW3\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE); } foreach ($propertyConfiguration as $innerKey => $innerValue) { if (is_array($innerValue)) { $this->modifyPropertyMappingConfiguration($innerValue, $propertyMappingConfiguration->forProperty($innerKey)); } $propertyMappingConfiguration->allowProperties($innerKey); } }