This converter will only be used on target types that are not entities or value objects (for those the
PersistentObjectConverter is used).
The target type can be overridden in the source by setting the __type key to the desired value.
The converter will return an instance of the target type with all properties given in the source array set to
the respective values. For the mechanics used to set the values see ObjectAccess::setProperty().
/** * @test */ public function getTypeOfChildPropertyShouldRemoveLeadingBackslashesForAnnotationParameters() { $this->mockReflectionService->expects($this->any())->method('getMethodParameters')->with('TheTargetType', '__construct')->will($this->returnValue([])); $this->mockReflectionService->expects($this->any())->method('hasMethod')->with('TheTargetType', 'setThePropertyName')->will($this->returnValue(false)); $this->mockReflectionService->expects($this->any())->method('getClassPropertyNames')->with('TheTargetType')->will($this->returnValue(['thePropertyName'])); $this->mockReflectionService->expects($this->any())->method('getPropertyTagValues')->with('TheTargetType', 'thePropertyName')->will($this->returnValue(['\\TheTypeOfSubObject'])); $configuration = new PropertyMappingConfiguration(); $configuration->setTypeConverterOptions(ObjectConverter::class, []); $this->assertEquals('TheTypeOfSubObject', $this->converter->getTypeOfChildProperty('TheTargetType', 'thePropertyName', $configuration)); }
/** * All properties in the source array except __identity are sub-properties. * * @param mixed $source * @return array */ public function getSourceChildPropertiesToBeConverted($source) { if (is_string($source)) { return []; } if (isset($source['__identity'])) { unset($source['__identity']); } return parent::getSourceChildPropertiesToBeConverted($source); }
/** * @test * @expectedException \Neos\Flow\Property\Exception\InvalidTargetException */ public function convertFromThrowsMeaningfulExceptionWhenTheTargetExpectsAnUnknownDependencyThatIsNotSpecifiedInTheSource() { $this->converter->convertFrom('irrelevant', \Neos\Flow\Tests\Functional\Property\Fixtures\TestClassWithThirdPartyClassConstructorInjection::class); }