8c3ffd2119243ae23d19c063e64be856943d32a1
[yaffs-website] / web / core / lib / Drupal / Core / Field / Plugin / Field / FieldType / TimestampItem.php
1 <?php
2
3 namespace Drupal\Core\Field\Plugin\Field\FieldType;
4
5 use Drupal\Core\Field\FieldStorageDefinitionInterface;
6 use Drupal\Core\Field\FieldItemBase;
7 use Drupal\Core\TypedData\DataDefinition;
8
9 /**
10  * Defines the 'timestamp' entity field type.
11  *
12  * @FieldType(
13  *   id = "timestamp",
14  *   label = @Translation("Timestamp"),
15  *   description = @Translation("An entity field containing a UNIX timestamp value."),
16  *   default_widget = "datetime_timestamp",
17  *   default_formatter = "timestamp",
18  *   constraints = {
19  *     "ComplexData" = {
20  *       "value" = {
21  *         "Range" = {
22  *           "min" = "-2147483648",
23  *           "max" = "2147483648",
24  *         }
25  *       }
26  *     }
27  *   }
28  * )
29  * )
30  */
31 class TimestampItem extends FieldItemBase {
32
33   /**
34    * {@inheritdoc}
35    */
36   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
37     $properties['value'] = DataDefinition::create('timestamp')
38       ->setLabel(t('Timestamp value'))
39       ->setRequired(TRUE);
40     return $properties;
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public static function schema(FieldStorageDefinitionInterface $field_definition) {
47     return [
48       'columns' => [
49         'value' => [
50           'type' => 'int',
51         ],
52       ],
53     ];
54   }
55
56 }