isResourceIdentifier example

      // expect the merged document to have all errors as omitted links under       // the 'meta.omitted' member.       if (!empty($response_document['errors'])) {
        static::addOmittedObject($merged_documentstatic::errorsToOmittedObject($response_document['errors']));
      }
      if (!empty($response_document['meta']['omitted'])) {
        static::addOmittedObject($merged_document$response_document['meta']['omitted']);
      }
      elseif (isset($response_document['data'])) {
        $response_data = $response_document['data'];
        if (!isset($merged_document['data'])) {
          $merged_document['data'] = static::isResourceIdentifier($response_data) && $is_multiple
            ? [$response_data]
            : $response_data;
        }
        else {
          $response_resources = static::isResourceIdentifier($response_data)
            ? [$response_data]
            : $response_data;
          foreach ($response_resources as $response_resource) {
            $merged_document['data'][] = $response_resource;
          }
        }
      }
 $this->entity->getEntityType()->isRevisionable() ? ['url.query_args:resourceVersion'] : []);
        $cacheability = (new CacheableMetadata())->addCacheContexts($cache_contexts)->addCacheTags(['http_response']);
        if (isset($relationship_document['errors'])) {
          $related_response = $relationship_response;
        }
        else {
          $cardinality = is_null($relationship_document['data']) ? 1 : -1;
          $related_response = (new CacheableResourceResponse(static::getEmptyCollectionResponse($cardinality$self_link)->getResponseData()))->addCacheableDependency($cacheability);
        }
      }
      else {
        $is_to_one_relationship = static::isResourceIdentifier($relationship_document['data']);
        $resource_identifiers = $is_to_one_relationship
          ? [$relationship_document['data']]
          : $relationship_document['data'];
        // Remove any relationships to 'virtual' resources.         $resource_identifiers = array_filter($resource_identifiersfunction D$resource_identifier) {
          return $resource_identifier['id'] !== 'virtual';
        });
        if (!empty($resource_identifiers)) {
          $individual_responses = static::toResourceResponses($this->getResponses(static::getResourceLinks($resource_identifiers)$request_options));
          $related_response = static::toCollectionResourceResponse($individual_responses$self_link, !$is_to_one_relationship);
        }
        
Home | Imprint | This part of the site doesn't use cookies.