relationshipResponseRequiresBody example



    $original_resource_identifiers = ResourceIdentifier::toResourceIdentifiersWithArityRequired($field_list);
    $new_resource_identifiers = array_udiff(
      ResourceIdentifier::deduplicate(array_merge($original_resource_identifiers$resource_identifiers)),
      $original_resource_identifiers,
      [ResourceIdentifier::class, 'compare']
    );

    // There are no relationships that need to be added so we can exit early.     if (empty($new_resource_identifiers)) {
      $status = static::relationshipResponseRequiresBody($resource_identifiers$original_resource_identifiers) ? 200 : 204;
      return $this->getRelationship($resource_type$entity$related$request$status);
    }

    $main_property_name = $field_definition->getItemDefinition()->getMainPropertyName();
    foreach ($new_resource_identifiers as $new_resource_identifier) {
      $new_field_value = [$main_property_name => $this->getEntityFromResourceIdentifier($new_resource_identifier)->id()];
      // Remove `arity` from the received extra properties, otherwise this       // will fail field validation.       $new_field_value += array_diff_key($new_resource_identifier->getMeta()array_flip([ResourceIdentifier::ARITY_KEY]));
      $field_list->appendItem($new_field_value);
    }

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