[FLOW3-general] Collection of Abstract Objects and Mapping to concrete by __type

Carsten Bleicker carsten at bleicker.de
Sat Feb 23 10:14:49 CET 2013


hi all,
having a model called Property wich contains a Collection of AbstractValueObjects.
Here is the Property Model and the notation of the descriped collection:

/**
 * A Property
 *
 * @Flow\Entity
 */
class Property {

	/**
	 * Relations to Abstract Value Objects
	*  Any Concrete Value Object using Table inheritance 
	 *
	 * @var \Doctrine\Common\Collections\Collection<\BLEICKER\Product\Domain\Model\AbstractValueObject>
	 * @ORM\ManyToMany(cascade={"persist","merge","detach"})
	 **/
	protected $abstractValueObjects;

}

the incoming arguments as json containing the following:
{
	"property":{
		"abstractValueObjects":[
			{"__type":"\\BLEICKER\\Product\\Domain\\Model\\StringValueObject","value":"Germany"},
			{"__type":"\\BLEICKER\\Product\\Domain\\Model\\IntegerValueObject","value":"22"},
			{"__type":"\\BLEICKER\\Product\\Domain\\Model\\PersonNameValueObject","firstname":"Donald","lastname":"Duck"}
		]
	}
}

i would expect, that the collection converter converts the input into the concrete object given by "__type".
but this does not happen. its allways tried to be converted into "\BLEICKER\Product\Domain\Model\AbstractValueObject".
i tried to set some mapping config, also without any effect :(
somebody can tell me what i have to do, to tell the propertyMapping to use __type on collection items?

here are my settings for the initialize action to set propertyMapping configurations:
public function initializeCreateAction() {
	parent::initializeCreateAction();
	$this->arguments[$this->resourceArgumentName]->getPropertyMappingConfiguration()->forProperty('abstractValueObjects')->allowAllProperties();
	$this->arguments[$this->resourceArgumentName]->getPropertyMappingConfiguration()->forProperty('abstractValueObjects.*')->setTypeConverterOption('TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter', \TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED, true);
	$this->arguments[$this->resourceArgumentName]->getPropertyMappingConfiguration()->forProperty('abstractValueObjects.*')->allowAllProperties();
}


thank you very much

carsten


More information about the FLOW3-general mailing list