PHP Class Neos\Flow\Property\TypeConverter\DateTimeConverter

For integers the default is to treat them as a unix timestamp. If a format to cerate from is given, this will be used instead. If source is a string it is expected to be formatted according to DEFAULT_DATE_FORMAT. This default date format can be overridden in the initialize*Action() method like this:: $this->arguments[''] ->getPropertyMappingConfiguration() ->forProperty('') // this line can be skipped in order to specify the format for all properties ->setTypeConverterOption(\Neos\Flow\Property\TypeConverter\DateTimeConverter::class, \Neos\Flow\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, ''); If the source is of type array, it is possible to override the format in the source:: array( 'date' => '', 'dateFormat' => '' ); By using an array as source you can also override time and timezone of the created DateTime object:: array( 'date' => '', 'hour' => '', // integer 'minute' => '', // integer 'seconds' => '', // integer 'timezone' => '', // string, see http://www.php.net/manual/timezones.php ); As an alternative to providing the date as string, you might supply day, month and year as array items each:: array( 'day' => '', // integer 'month' => '', // integer 'year' => '', // integer );
Inheritance: extends AbstractTypeConverter
Mostrar archivo Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$priority integer
$sourceTypes array
$targetType string

Public Methods

Method Description
canConvertFrom ( string $source, string $targetType ) : boolean If conversion is possible.
convertFrom ( string | integer | array $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : DateTime | Error Converts $source to a \DateTime using the configured dateFormat

Protected Methods

Method Description
getDefaultDateFormat ( Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string Determines the default date format to use for the conversion.
isDatePartKeysProvided ( array $source ) : boolean Returns whether date information (day, month, year) are present as keys in $source.
overrideTimeIfSpecified ( DateTime $date, array $source ) : void Overrides hour, minute & second of the given date with the values in the $source array

Method Details

canConvertFrom() public method

If conversion is possible.
public canConvertFrom ( string $source, string $targetType ) : boolean
$source string
$targetType string
return boolean

convertFrom() public method

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
return DateTime | Neos\Flow\Validation\Error

getDefaultDateFormat() protected method

If no format is specified in the mapping configuration DEFAULT_DATE_FORMAT is used.
protected getDefaultDateFormat ( Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : string
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
return string

isDatePartKeysProvided() protected method

Returns whether date information (day, month, year) are present as keys in $source.
protected isDatePartKeysProvided ( array $source ) : boolean
$source array
return boolean

overrideTimeIfSpecified() protected method

Overrides hour, minute & second of the given date with the values in the $source array
protected overrideTimeIfSpecified ( DateTime $date, array $source ) : void
$date DateTime
$source array
return void

Property Details

$priority protected_oe property

protected int $priority
return integer

$sourceTypes protected_oe property

protected array $sourceTypes
return array

$targetType protected_oe property

protected string $targetType
return string