convertFrom() 공개 메소드

Converts $source to a \DateTime using the configured dateFormat
public convertFrom ( string | integer | array $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : DateTime | Error
$source string | integer | array the string to be converted to a \DateTime object
$targetType string must be "DateTime"
$convertedChildProperties array not used currently
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
리턴 DateTime | Neos\Flow\Validation\Error
    /**
     * @test
     */
    public function convertFromSupportsDateTimeSubClasses()
    {
        $className = 'DateTimeSubClass' . md5(uniqid(mt_rand(), true));
        if (version_compare(PHP_VERSION, '7.0.0-dev')) {
            eval('
			class ' . $className . ' extends \\DateTime {
				public static function createFromFormat($format, $time, $timezone = NULL) {
					return new ' . $className . '();
				}
				public function foo() { return "Bar"; }
			}
		');
        } else {
            eval('
				class ' . $className . ' extends \\DateTime {
					public static function createFromFormat($format, $time, \\DateTimeZone $timezone = NULL) {
						return new ' . $className . '();
					}
					public function foo() { return "Bar"; }
				}
			');
        }
        $date = $this->converter->convertFrom('2005-08-15T15:52:01+00:00', $className);
        $this->assertInstanceOf($className, $date);
        $this->assertSame('Bar', $date->foo());
    }