*/
abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigInterface {
+ use FieldInputValueNormalizerTrait;
+
/**
* The field ID.
*
return $changed;
}
-
/**
* {@inheritdoc}
*/
// 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();
* {@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;
}
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();
+ }
+
}