You are here

public function UuidItem::applyDefaultValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php \Drupal\Core\Field\Plugin\Field\FieldType\UuidItem::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/UuidItem.php, line 40
Contains \Drupal\Core\Field\Plugin\Field\FieldType\UuidItem.

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