getEntityFromResourceIdentifier example

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);
    }

    $this->validate($entity);
    $entity->save();

    $final_resource_identifiers = ResourceIdentifier::toResourceIdentifiersWithArityRequired($field_list);
    $status = static::relationshipResponseRequiresBody($resource_identifiers$final_resource_identifiers) ? 200 : 204;
    
Home | Imprint | This part of the site doesn't use cookies.