Create a correctly canonicalized value for a field, depending on its name.

@param string $fieldname
@param string $fieldvalue

@return string
969656
private function canonicalizeFieldValue($fieldname, $fieldvalue)
    {
        switch ($fieldname) {
            case 'email':
                return strtolower(trim($fieldvalue));

            case 'username':
                return strtolower(preg_replace('/[^a-zA-Z0-9_\\-]/', '', $fieldvalue));

            default:
                return trim($fieldvalue);
        }
    }
198279
protected function Value($fieldName, $defaultValue) {
        $form = Form::Current();
        if (!$form) {
            return $defaultValue;
        }
        return $form->GetValue($fieldName, $defaultValue);
    }
1372981
public function fromPersistenceValue(FieldValue $fieldValue)
    {
        if ($fieldValue->externalData === null) {
            return $this->getEmptyValue();
        }

        return $this->fromHash($fieldValue->externalData);
    }
311542
public function fromPersistenceValue(FieldValue $fieldValue)
    {
        if ($fieldValue->externalData === null) {
            return $this->getEmptyValue();
        }

        return new Value(
            $fieldValue->externalData,
            $fieldValue->data['text']
        );
    }
326175
public function handleField(FieldValue $fieldValue, Closure $next): FieldValue
    {
        if ($this->directiveHasArgument('resolver')) {
            [$className, $methodName] = $this->getMethodArgumentParts('resolver');

            $namespacedClassName = $this->namespaceClassName(
                $className,
                $fieldValue->defaultNamespacesForParent()
            );

            $resolver = Utils::constructResolver($namespacedClassName, $methodName);
        } else {
            $resolver = function (int $childrenComplexity, array $args): int {
                $complexity = Arr::get(
                    $args,
                    'first',
                    Arr::get($args, config('lighthouse.pagination_amount_argument'), 1)
                );

                return $childrenComplexity * $complexity;
            };
        }

        return $next(
            $fieldValue->setComplexity($resolver)
        );
    }
305627
public function addFieldValue(FieldValueInterface $fieldValue)
    {
        $this->fieldValues[] = $fieldValue;
        $fieldValue->setContent($this);

        return $this;
    }
466669
public function render(FieldValueInterface $fieldValue)
    {
        $value = $fieldValue->getValue();
        $value = unserialize($value);

        if (empty($value['src'])) {
            return '';
        }

        $fileName = $this->uploadManager->getTargetDir() . DIRECTORY_SEPARATOR . $value['src'];
        if (!file_exists($fileName)) {
            return '';
        }

        $fileName = $this->assetPackages->getUrl($this->uploadManager->getWebPath() . '/' . $value['src']);

        return '<img src="' . $fileName . '" alt="' . $value['alt'] . '"/>';
    }
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);
            }
        );
    }
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;
    }
1354406
public function render(FieldValueInterface $fieldValue)
    {
        $options = $this->getFieldOptionsArray($fieldValue->getField());
        $value = unserialize($fieldValue->getValue());

        $values = [];
        foreach ($value as $valueId) {
            if (!empty($options[$valueId])) {
                $values[] = $options[$valueId];
            }
        }

        return implode(',', $values);
    }
750401
public function fromPersistenceValue(FieldValue $fieldValue)
    {
        if ($fieldValue->externalData === null) {
            return $this->getEmptyValue();
        }

        $result = parent::fromPersistenceValue($fieldValue);

        $result->hasController = (isset($fieldValue->externalData['hasController'])
            ? $fieldValue->externalData['hasController']
            : false);
        $result->autoplay = (isset($fieldValue->externalData['autoplay'])
            ? $fieldValue->externalData['autoplay']
            : false);
        $result->loop = (isset($fieldValue->externalData['loop'])
            ? $fieldValue->externalData['loop']
            : false);
        $result->height = (isset($fieldValue->externalData['height'])
            ? $fieldValue->externalData['height']
            : 0);
        $result->width = (isset($fieldValue->externalData['width'])
            ? $fieldValue->externalData['width']
            : 0);

        return $result;
    }
605877
public function cuSelectOneDataSet($tableName, $fieldName, $fieldValue)
    {

        $where         = " $fieldName='$fieldValue' ";
        $dataSetsArray = $this->cuSelectAsArray($tableName, $where);

        $dataSetArray = null;
        if (array_key_exists(0, $dataSetsArray)) {
            $dataSetArray = $dataSetsArray[0];
        }

        return $dataSetArray;
    }
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;
    }
178855
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        $storageFieldValue->dataText = isset($value->data['text'])
            ? $value->data['text']
            : null;
        $storageFieldValue->dataInt = isset($value->data['urlId'])
            ? $value->data['urlId']
            : null;
    }
990335
private function getListViewConfigurationValue($fieldName)
    {
        if (empty($fieldName)) {
            throw new \InvalidArgumentException('$fieldName must not be empty.', 1331489528);
        }

        if (!isset($this->conf['listView.'])
            || !isset($this->conf['listView.'][$fieldName])
        ) {
            return '';
        }

        return $this->conf['listView.'][$fieldName];
    }
859566
public function updateFieldValueValue(FieldValueInterface $fieldValue, $changeSet)
    {
        if (!isset($changeSet['value'])) {
            return;
        }

        $oldValue = unserialize($changeSet['value'][0]);
        $newValue = unserialize($changeSet['value'][1]);

        if ($newValue['src'] == '' && !$newValue['delete']) {
            $newValue['src'] = $oldValue['src'];
        }

        if ($newValue['delete']) {
            $this->uploadManager->remove($oldValue['src']);
        }

        unset($newValue['delete']);

        $fieldValue->setValue(serialize($newValue));
    }
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();
            }
        );
    }