X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FField%2FFieldConfigBase.php;h=0d58b65614d0c10b0f6435e654b8484feb601742;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=a32ff423beac9996cdc5dee733d657a588364615;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Field/FieldConfigBase.php b/web/core/lib/Drupal/Core/Field/FieldConfigBase.php index a32ff423b..0d58b6561 100644 --- a/web/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/web/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -12,6 +12,8 @@ use Drupal\Core\Field\TypedData\FieldItemDataDefinition; */ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigInterface { + use FieldInputValueNormalizerTrait; + /** * The field ID. * @@ -263,7 +265,6 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn return $changed; } - /** * {@inheritdoc} */ @@ -394,6 +395,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn // Allow custom default values function. if ($callback = $this->getDefaultValueCallback()) { $value = call_user_func($callback, $entity, $this); + $value = $this->normalizeValue($value, $this->getFieldStorageDefinition()->getMainPropertyName()); } else { $value = $this->getDefaultValueLiteral(); @@ -414,18 +416,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn * {@inheritdoc} */ public function setDefaultValue($value) { - if (!is_array($value)) { - if ($value === NULL) { - $value = []; - } - $key = $this->getFieldStorageDefinition()->getPropertyNames()[0]; - // Convert to the multi value format to support fields with a cardinality - // greater than 1. - $value = [ - [$key => $value], - ]; - } - $this->default_value = $value; + $this->default_value = $this->normalizeValue($value, $this->getFieldStorageDefinition()->getMainPropertyName()); return $this; }