validateFields example

foreach ($payload[$field->getPropertyName()] as $key => $entityPayload) {
                $payload[$field->getPropertyName()][$key] = $this->convertPayload(
                    $field instanceof ManyToManyAssociationField ? $field->getToManyReferenceDefinition() : $field->getReferenceDefinition(),
                    $entityPayload,
                    $conversionException,
                    $pointer . '/' . $key . '/' . $field->getPropertyName()
                );
            }
        }

        $payload = $this->validateFields($definition$payload);

        return $payload;
    }

    /** * @param array<string, mixed> $payload * * @return array<string, mixed> */
    private function validateFields(EntityDefinition $definition, array $payload): array
    {
        
if ($criteria->loadAssociations) {
            $items = $this->fieldResolver->resolveFields($this->type, $items);
        }

        $result->items = $items;

        return $result;
    }

    public function save(array $data, ?int $id = null): int
    {
        $this->validateFields($data);
        $data = $this->filterFields($data);
        $data = $this->quoteFields($data);

        $data['updated_at'] = date('Y-m-d H:i:s');
        if ($id) {
            $this->connection->update($this->type->getTableName()$data['id' => $id]);
        } else {
            $data['created_at'] = date('Y-m-d H:i:s');
            $this->connection->insert($this->type->getTableName()$data);
            $id = (int) $this->connection->lastInsertId();
        }

        
Home | Imprint | This part of the site doesn't use cookies.