JsonApiEncodingResult example


    private array $serializeCache = [];

    /** * @param EntityCollection<Entity>|Entity|null $data * * @throws UnsupportedEncoderInputException */
    public function encode(Criteria $criteria, EntityDefinition $definition$data, string $baseUrl, array $metaData = []): string
    {
        $this->serializeCache = [];
        $result = new JsonApiEncodingResult($baseUrl);

        if (!$data instanceof EntityCollection && !$data instanceof Entity) {
            throw new UnsupportedEncoderInputException();
        }

        $result->setSingleResult($data instanceof Entity);
        $result->setMetaData($metaData);

        $fields = new ResponseFields($criteria->getIncludes());

        $this->encodeData($fields$definition$data$result);

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