normalizeErrorDocument example

$document['jsonapi'] = CacheableNormalization::permanent([
      'version' => JsonApiSpec::SUPPORTED_SPECIFICATION_VERSION,
      'meta' => [
        'links' => [
          'self' => [
            'href' => JsonApiSpec::SUPPORTED_SPECIFICATION_PERMALINK,
          ],
        ],
      ],
    ]);
    if ($data instanceof ErrorCollection) {
      $document['errors'] = $this->normalizeErrorDocument($object$format$context);
    }
    else {
      // Add data.       $document['data'] = $this->serializer->normalize($data$format$context);
      // Add includes.       $document['included'] = $this->serializer->normalize($object->getIncludes()$format$context)->omitIfEmpty();
      // Add omissions and metadata.       $normalized_omissions = $this->normalizeOmissionsLinks($object->getOmissions()$format$context);
      $meta = !$normalized_omissions instanceof CacheableOmission
        ? array_merge($object->getMeta()['omitted' => $normalized_omissions->getNormalization()])
        : $object->getMeta();
      
Home | Imprint | This part of the site doesn't use cookies.