Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / Field / Plugin / Field / FieldType / CreatedItem.php
1 <?php
2
3 namespace Drupal\Core\Field\Plugin\Field\FieldType;
4
5 /**
6  * Defines the 'created' entity field type.
7  *
8  * @FieldType(
9  *   id = "created",
10  *   label = @Translation("Created"),
11  *   description = @Translation("An entity field containing a UNIX timestamp of when the entity has been created."),
12  *   no_ui = TRUE,
13  *   default_widget = "datetime_timestamp",
14  *   default_formatter = "timestamp"
15  * )
16  */
17 class CreatedItem extends TimestampItem {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function applyDefaultValue($notify = TRUE) {
23     parent::applyDefaultValue($notify);
24     // Created fields default to the current timestamp.
25     $this->setValue(['value' => REQUEST_TIME], $notify);
26     return $this;
27   }
28
29 }