You are here

protected function EntityResource::doPatchMultipleRelationship in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::doPatchMultipleRelationship()

Update a to-many relationship.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The requested entity.

\Drupal\Core\Field\EntityReferenceFieldItemListInterface $parsed_field_list: The entity reference field list of items to add, or a response object in case of error.

1 call to EntityResource::doPatchMultipleRelationship()
EntityResource::doPatchIndividualRelationship in src/Controller/EntityResource.php
Update a to-one relationship.

File

src/Controller/EntityResource.php, line 729

Class

EntityResource
Process all entity requests.

Namespace

Drupal\jsonapi\Controller

Code

protected function doPatchMultipleRelationship(EntityInterface $entity, EntityReferenceFieldItemListInterface $parsed_field_list) {
  $field_name = $parsed_field_list
    ->getName();
  $field_access = $parsed_field_list
    ->access('edit', NULL, TRUE);
  if (!$field_access
    ->isAllowed()) {
    throw new EntityAccessDeniedHttpException($entity, $field_access, '/data/relationships/' . $field_name, sprintf('The current user is not allowed to PATCH the selected field (%s).', $field_name));
  }
  $entity->{$field_name} = $parsed_field_list;
}