Create a default text field

@param string $fieldName
@param null   $defaultValue

@return DateField
770697
public function createField($fieldName, $defaultValue = null)
    {
        /** @var DateField $dateField */
        $dateField = parent::createField($fieldName, $defaultValue);

        if ($this->MinDate) {
            $dateField->setConfig('min', $this->dbObject('MinDate')->Format('Y-m-d'));
        }

        if ($this->MaxDate) {
            $dateField->setConfig('max', $this->dbObject('MaxDate')->Format('Y-m-d'));
        }

        return $dateField;
    }
1311628
public function serialize(FieldValue $fieldValue, array $options = [])
    {
        $serialized = [
            'id' => $fieldValue->getUuid(),
        ];

        if (in_array(Options::SERIALIZE_MINIMAL, $options)) {
            $serialized = array_merge($serialized, [
                'field' => [
                    'id' => $fieldValue->getField()->getUuid(),
                ],
                'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']),
            ]);
        } else {
            $serialized = array_merge($serialized, [
                'field' => $this->fieldSerializer->serialize($fieldValue->getField(), [Options::SERIALIZE_MINIMAL]),
                'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']),
            ]);
        }

        return $serialized;
    }
911204
public function getValueFor($name, $defaultValue = null)
    {
        if (!$this->hasParameter($name)) {
            return $defaultValue;
        }
        return $this->parameters[strtolower($name)]->getValue();
    }
423027
public function extractDefault(ColumnSchema $field, $defaultValue)
    {
        if ($defaultValue === 'true') {
            $field->defaultValue = true;
        } elseif ($defaultValue === 'false') {
            $field->defaultValue = false;
        } elseif (strpos($defaultValue, 'nextval') === 0) {
            $field->defaultValue = null;
        } elseif (preg_match('/^\'(.*)\'::/', $defaultValue, $matches)) {
            parent::extractDefault($field, str_replace("''", "'", $matches[1]));
        } elseif (preg_match('/^(-?\d+(\.\d*)?)(::.*)?$/', $defaultValue, $matches)) {
            parent::extractDefault($field, $matches[1]);
        } else {
            // could be a internal function call like setting uuids
            $field->defaultValue = $defaultValue;
        }
    }
318026
public function extractDefault(ColumnSchema $field, $defaultValue)
    {
        if ($field->dbType === 'timestamp' && $defaultValue === 'CURRENT_TIMESTAMP') {
            $defaultValue = null;
        } else {
            $defaultValue = strcasecmp($defaultValue, 'null') ? $defaultValue : null;
        }

        if (is_string($defaultValue)) // PHP 5.2.6 adds single quotes while 5.2.0 doesn't
        {
            $defaultValue = trim($defaultValue, "'\"");
        }

        parent::extractDefault($field, $defaultValue);
    }
650675
public function resolveField(FieldValue $fieldValue): FieldValue
    {
        $method = $this->directiveArgValue(
            'name',
            $this->definitionNode->name->value
        );

        return $fieldValue->setResolver(
            function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($method) {
                return call_user_func([$root, $method], $root, $args, $context, $resolveInfo);
            }
        );
    }
1320288
public function set_value($field = '', $default = '')
    {
        if (!isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) {
            return $default;
        }
        return $this->_field_data[$field]['postdata'];
    }
1284278
public function setFieldValue($fieldName, $value)
    {
        if (isset($this->originalValues[$fieldName])
            && $this->originalValues[$fieldName] === $value
        ) {
            # the given value is the same as the original value;
            # ignore any given value
            unset($this->givenValues[$fieldName]);
        } elseif (isset($this->originalValues[$fieldName])
            && $this->originalValues[$fieldName] !== $value
            && isset($this->defaults[$fieldName])
            && $this->defaults[$fieldName] === $value
        ) {
            # the given value is the same as a default value, but different from
            # the original value; change it
            $this->givenValues[$fieldName] = $value;
        } elseif (isset($this->defaults[$fieldName])
            && $this->defaults[$fieldName] === $value
        ) {
            # the given value is the same as the default value;
            # ignore any given value
            unset($this->givenValues[$fieldName]);
        } else {
            $this->givenValues[$fieldName] = $value;
        }
        return $this;
    }
385582
protected function extractDefault($defaultValue)
	{
		if(stripos($defaultValue,'timestamp')!==false)
			$this->defaultValue=null;
		else
			parent::extractDefault($defaultValue);
	}
256780
protected function _getUpdateFieldValue($fieldName, $field)
    {
        $fieldValue = null;
        if ($field instanceof Field) {
            $fieldValue = $field->getRawValue();
        } elseif (isset($field->value)) {
            $fieldValue = $field->value;
        }

        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        //Check if this field value is null AND it can be null according if not returning default value
        if ((null === $fieldValue)) {
            if ($this->_canFieldBeNull($fieldName)) {
                return 'null';
            } elseif ($fieldValue = $this->_getFieldDefaultValue($fieldName)) {
                return $database->quote($fieldValue);
            }
        }

        return $database->quote($fieldValue);
    }
321291
public function resolveField(FieldValue $fieldValue): FieldValue
    {
        /** @var string|null $guard */
        $guard = $this->directiveArgValue('guard');

        return $fieldValue->setResolver(
            function () use ($guard): ?Authenticatable {
                return $this
                    ->authFactory
                    ->guard($guard)
                    ->user();
            }
        );
    }
412838
protected function getFieldValue(
        Crawler $node,
        $defaultValue,
        $callback = null,
        $funcName = 'text',
        $funcParam = ''
    ) {
        if ($callback == null) {
            $callback = function ($value) {
                return (new DefaultSanitizer)->clean($value);
            };
        }

        if ($node->count()) {
            return $callback($node->$funcName($funcParam));
        }

        return $defaultValue;
    }
1286675
public function createField($fieldName, $defaultValue = null)
    {
        /** @var OptionsetField $field */
        $field = parent::createField($fieldName, $defaultValue);
        $field->setSource($this->Options()->map()->toArray());
        $field->setValue($defaultValue);
        return $field;
    }
935098
public function get($param, $defaultValue = null)
    {
        return array_key_exists($param, $this->config) ? $this->config[$param] : $defaultValue;
    }
1287393
public function setDefaultValue($defaultValue): Parameter
    {
        $this->isOptional = true;
        $this->defaultValue = $defaultValue;

        return $this;
    }
237119
public function getField($config, $field, $default = '')
    {
        $data = (isset($config['config'][$field])) ? $config['config'][$field] : $default;

        return $data;
    }
985581
public function get($key, $defaultValue = null)
    {
        if ($this->has($key)) {
            return $this->attributes[$key];
        }

        return $defaultValue;
    }