Newer
Older
Angie Byron
committed
<?php
namespace Drupal\Core\Field\Plugin\Field\FieldType;
Alex Pott
committed
use Drupal\Core\Field\FieldStorageDefinitionInterface;
Angie Byron
committed
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\TypedData\DataDefinition;
/**
* Defines the 'timestamp' entity field type.
*
* @FieldType(
* id = "timestamp",
* label = @Translation("Timestamp"),
* description = @Translation("An entity field containing a UNIX timestamp value."),
* default_widget = "datetime_default",
* default_formatter = "timestamp",
* constraints = {
* "ComplexData" = {
* "value" = {
* "Range" = {
* "min" = "-2147483648",
* "max" = "2147483648",
* }
* }
* }
* }
* )
Angie Byron
committed
* )
*/
class TimestampItem extends FieldItemBase {
/**
* {@inheritdoc}
*/
Alex Pott
committed
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
Angie Byron
committed
$properties['value'] = DataDefinition::create('timestamp')
->setLabel(t('Timestamp value'))
->setRequired(TRUE);
Angie Byron
committed
return $properties;
}
/**
* {@inheritdoc}
*/
Alex Pott
committed
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return [
'columns' => [
'value' => [
Angie Byron
committed
'type' => 'int',
],
],
];
Angie Byron
committed
}