field_collection

Drupal 8 update entity field collection fields programmatically

Submitted by august on Tue, 07/25/2017 - 23:59
  /**
   * Responds to entity PATCH requests.
   *
   * @param \Drupal\Core\Entity\EntityInterface $original_entity
   *   The original entity object.
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity.
   *
   * @return \Drupal\rest\ModifiedResourceResponse
   *   The HTTP response object.
   *
   * @throws \Symfony\Component\HttpKernel\Exception\HttpException
   */
  public function patch(EntityInterface $original_entity, EntityInterface $entity = NULL) {
    
    ....
    
    foreach ($entity->_restSubmittedFields as $field_name) {
      $field = $entity->get($field_name);