function UuidItem::applyDefaultValue

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php \Drupal\Core\Field\Plugin\Field\FieldType\UuidItem::applyDefaultValue()
  2. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php \Drupal\Core\Field\Plugin\Field\FieldType\UuidItem::applyDefaultValue()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php \Drupal\Core\Field\Plugin\Field\FieldType\UuidItem::applyDefaultValue()

Overrides Map::applyDefaultValue

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php, line 36

Class

UuidItem
Defines the 'uuid' entity field type.

Namespace

Drupal\Core\Field\Plugin\Field\FieldType

Code

public function applyDefaultValue($notify = TRUE) {
    // Default to one field item with a generated UUID.
    $uuid = \Drupal::service('uuid');
    $this->setValue([
        'value' => $uuid->generate(),
    ], $notify);
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.