ExpectedArrayException example

$field->getReferenceDefinition()::class
                D
            );
        }
        $key = $field->getPropertyName();
        $value = $data[$key] ?? null;
        if ($value === null) {
            return $data;
        }

        if (!\is_array($value)) {
            throw new ExpectedArrayException($parameters->getPath());
        }

        $fkField = $parameters->getDefinition()->getFields()->getByStorageName($field->getStorageName());
        if ($fkField === null) {
            throw new \RuntimeException(
                sprintf(
                    'Could not find FK field "%s" from field "%s"',
                    $field->getStorageName(),
                    $parameters->getDefinition()::class
                D
            );
        }
if (!$field instanceof OneToOneAssociationField) {
            throw DataAbstractionLayerException::invalidSerializerField(OneToOneAssociationField::class$field);
        }

        $key = $field->getPropertyName();
        $value = $data[$key] ?? null;
        if ($value === null) {
            return $data;
        }

        if (!\is_array($value)) {
            throw new ExpectedArrayException($parameters->getPath());
        }

        /** @var Field $keyField */
        $keyField = $parameters->getDefinition()->getFields()->getByStorageName($field->getStorageName());
        $reference = $field->getReferenceDefinition();

        if ($keyField instanceof FkField) {
            $referenceField = $field->getReferenceField();
            $pkField = $reference->getFields()->getByStorageName($referenceField);
            if ($pkField === null) {
                throw new \RuntimeException(
                    
$value[$languageId] = $fields;
            } else {
                $value[$languageId] = array_merge($value[$languageId]$value[$identifier]);
            }

            unset($value[$identifier]);
        }

        $translations = [];
        foreach ($value as $keyValue => $subResources) {
            if (!\is_array($subResources)) {
                throw new ExpectedArrayException($path);
            }

            // See above for Supported formats             $languageId = $keyValue;
            if (is_numeric($languageId) && $languageId >= 0 && $languageId < (is_countable($value) ? \count($value) : 0)) {
                // languageId is a property of $subResources. Also see formats above                 if (isset($subResources[$languagePropName])) {
                    $languageId = $subResources[$languagePropName];
                } elseif (isset($subResources['language']['id'])) {
                    $languageId = $subResources['language']['id'];
                } else {
                    
if (!$fkField) {
            throw new \RuntimeException(sprintf('Can not find fk field for accessor %s.%s', $reference->getEntityName()$field->getReferenceField()));
        }

        // allows to reset the association for a none cascade delete         $fk = $fkField->getPropertyName();

        foreach ($value as $keyValue => $subresources) {
            $currentId = $id;
            if (!\is_array($subresources)) {
                throw new ExpectedArrayException($parameters->getPath() . '/' . $key);
            }

            if (\array_key_exists($fk$subresources) && $subresources[$fk] === null) {
                $currentId = null;
            }

            $subresources[$fk] = $currentId;

            $clonedParams = $parameters->cloneForSubresource(
                $reference,
                $parameters->getPath() . '/' . $key
            );
$key = $field->getPropertyName();
        $value = $data[$key] ?? null;

        if ($value === null) {
            return $data;
        }

        $referencedDefinition = $field->getMappingDefinition();

        if (!\is_array($value)) {
            throw new ExpectedArrayException($parameters->getPath() . '/' . $key);
        }

        $mappingAssociation = $this->getMappingAssociation($referencedDefinition$field);

        foreach ($value as $keyValue => $subresources) {
            $mapped = $subresources;
            if ($mappingAssociation) {
                $mapped = $this->map($referencedDefinition$mappingAssociation$subresources);
            }

            if (!\is_array($mapped)) {
                
Home | Imprint | This part of the site doesn't use cookies.