You are here

public function CreatedItem::applyDefaultValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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

\Drupal\Core\TypedData\TypedDataInterface Returns itself to allow for chaining.

Overrides Map::applyDefaultValue

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php, line 27
Contains \Drupal\Core\Field\Plugin\Field\FieldType\CreatedItem.

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(array(
    'value' => REQUEST_TIME,
  ), $notify);
  return $this;
}