Neos\Flow\Property\TypeConverter\ObjectConverter::canConvertFrom PHP Method

canConvertFrom() public method

Only convert non-persistent types
public canConvertFrom ( mixed $source, string $targetType ) : boolean
$source mixed
$targetType string
return boolean
    public function canConvertFrom($source, $targetType)
    {
        return !($this->reflectionService->isClassAnnotatedWith($targetType, Flow\Entity::class) || $this->reflectionService->isClassAnnotatedWith($targetType, Flow\ValueObject::class) || $this->reflectionService->isClassAnnotatedWith($targetType, \Doctrine\ORM\Mapping\Entity::class));
    }

Usage Example

コード例 #1
0
 /**
  * @test
  * @dataProvider dataProviderForCanConvert
  */
 public function canConvertFromReturnsTrueIfClassIsTaggedWithEntityOrValueObject($isEntity, $isValueObject, $expected)
 {
     if ($isEntity) {
         $this->mockReflectionService->expects($this->once())->method('isClassAnnotatedWith')->with('TheTargetType', Flow\Entity::class)->will($this->returnValue($isEntity));
     } else {
         $this->mockReflectionService->expects($this->at(0))->method('isClassAnnotatedWith')->with('TheTargetType', Flow\Entity::class)->will($this->returnValue($isEntity));
         $this->mockReflectionService->expects($this->at(1))->method('isClassAnnotatedWith')->with('TheTargetType', Flow\ValueObject::class)->will($this->returnValue($isValueObject));
     }
     $this->assertEquals($expected, $this->converter->canConvertFrom('myInputData', 'TheTargetType'));
 }