resolveIncludes example


    public function decode(string $data, string $format, array $context = [])
    {
        $decodedData = (new JsonDecode([JsonDecode::ASSOCIATIVE => true]))->decode($data, 'json');

        if (!\is_array($decodedData) || !\array_key_exists('data', $decodedData)) {
            throw new UnexpectedValueException('Input not a valid JSON:API data object.');
        }

        $includes = [];
        if (\array_key_exists('included', $decodedData)) {
            $includes = $this->resolveIncludes($decodedData['included']);
        }

        if ($this->isCollection($decodedData['data'])) {
            return $this->decodeCollection($decodedData$includes);
        }

        return $this->decodeResource($decodedData['data']$includes);
    }

    /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.