PHP Класс 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 );
Наследование: extends AbstractTypeConverter
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$priority integer
$sourceTypes array
$targetType string

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Описание методов

canConvertFrom() публичный Метод

If conversion is possible.
public canConvertFrom ( string $source, string $targetType ) : boolean
$source string
$targetType string
Результат boolean

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

getDefaultDateFormat() защищенный Метод

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
Результат string

isDatePartKeysProvided() защищенный Метод

Returns whether date information (day, month, year) are present as keys in $source.
protected isDatePartKeysProvided ( array $source ) : boolean
$source array
Результат boolean

overrideTimeIfSpecified() защищенный Метод

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
Результат void

Описание свойств

$priority защищенное свойство

protected int $priority
Результат integer

$sourceTypes защищенное свойство

protected array $sourceTypes
Результат array

$targetType защищенное свойство

protected string $targetType
Результат string