You are here

public function CreatedItem::applyDefaultValue in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php \Drupal\Core\Field\Plugin\Field\FieldType\CreatedItem::applyDefaultValue()
  2. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php \Drupal\Core\Field\Plugin\Field\FieldType\CreatedItem::applyDefaultValue()

Applies the default value.

Parameters

bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.

Return value

$this Returns itself to allow for chaining.

Overrides Map::applyDefaultValue

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php, line 22

Class

CreatedItem
Defines the 'created' entity field type.

Namespace

Drupal\Core\Field\Plugin\Field\FieldType

Code

public function applyDefaultValue($notify = TRUE) {
  parent::applyDefaultValue($notify);

  // Created fields default to the current timestamp.
  $this
    ->setValue([
    'value' => REQUEST_TIME,
  ], $notify);
  return $this;
}