Change record status: 
Project: 
Introduced in branch: 
8.0.x
Introduced in version: 
8.0.x-BETA15
Description: 

The default_value property of the Drupal\Core\Field\BaseFieldDefinition and Drupal\Core\Field\FieldConfigBase classes is now private (following the pattern adopted for all config entities), and cannot be accessed directly.

That property, and the related default_value_callback property (which was already private), already had setter methods :

  • ::setDefaultValue(), to assign a literal default value
  • ::setDefaultValueCallback(), to assign a callback that computes a default value at runtime

But the corresponding getter methods were missing, and have been added as part of this change:

  • ::getDefaultValueLiteral(), for the literal default value (if any)
  • ::getDefaultValueCallback(), for the callback (if any)

Reading those two values directly should however be rarely needed. As a reminder, the already existing getDefaultValue() method is the preferred way to get 'the default value to use at runtime for the field in a given entity", as it collates the above and uses either the callback or the litteral value, depending on which has been specified (if both, the callback takes precedence).

Impacts: 
Module developers