Path

ez components / documentation / api reference / latest / persistentobject


eZ Components latest

PersistentObject: ezcPersistentPropertyDateTimeConverter

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcPersistentPropertyDateTimeConverter

Property converter class for date/time values. [source]

Implemented Interfaces

An instance of this class can be used with ezcPersistentObjectProperty in a ezcPersistentObjectDefinition to indicate, that a database date/time value (represented by a unix timestamp integer value) should be converted to a PHP DateTime object.

Method Summary

public DateTime|null fromDatabase( $databaseValue )
Converts unix timestamp to DateTime instance.
public int|null toDatabase( $propertyValue )
Converts a DateTime object into a unix timestamp.
public static ezcPersistentPropertyConverter __set_state( $state )
Method for de-serialization after var_export().

Methods

fromDatabase

DateTime|null fromDatabase( int|null $databaseValue )
Converts unix timestamp to DateTime instance.
This method is called right after a column value has been read from the database, given the $databaseValue. The value returned by this method is then assigned to the persistent objects property.
The given integer value $databaseValue is handled as a date/time value in unix timestamp representation. A corresponding DateTime object is returned, representing the same date/time value.

Parameters

Name Type Description
$databaseValue int|null  

Throws

ClassDescription
ezcBaseValueException if the given $databaseValue is not an integer.

toDatabase

int|null toDatabase( DateTime|null $propertyValue )
Converts a DateTime object into a unix timestamp.
This method is called right before a property value is written to the database, given the $propertyValue. The value returned by this method is then written back to the database.
The method expects a DateTime object in $propertyValue and returns the date/time value represented by it as an integer value in unix timestamp format.

Parameters

Name Type Description
$propertyValue DateTime|null  

Throws

ClassDescription
ezcBaseValueException if the given $propertyValue is not an instance of DateTime.

__set_state

ezcPersistentPropertyConverter __set_state( $state )
Method for de-serialization after var_export().
This methid must be implemented to allow proper de-serialization of converter objects, when they are exported using http://www.php.net/var_export.

Parameters

Name Type Description
$state array  

Last updated: Mon, 21 Dec 2009