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=e53e84b6c89ba1a2979a8dea65771604b04bb209;hpb=bfbba508964731508b9bd6d5835c2edc858db95b;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Field/FieldConfigBase.php b/web/core/lib/Drupal/Core/Field/FieldConfigBase.php index e53e84b6c..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; } @@ -591,4 +582,15 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn return $this; } + /** + * {@inheritdoc} + */ + public function isInternal() { + // Respect the definition, otherwise default to TRUE for computed fields. + if (isset($this->definition['internal'])) { + return $this->definition['internal']; + } + return $this->isComputed(); + } + }