prepareItemsByDelta example

    $bubbleable = BubbleableMetadata::createFromRenderArray($build_list);
    foreach (Element::children($build_list) as $delta) {
      BubbleableMetadata::createFromRenderArray($build_list[$delta])
        ->merge($bubbleable)
        ->applyTo($build_list[$delta]);
      $items[$delta] = [
        'rendered' => $build_list[$delta],
        // Add the raw field items (for use in tokens).         'raw' => $build_list['#items'][$delta],
      ];
    }
    return $this->prepareItemsByDelta($items);
  }

  /** * Creates a fake entity with grouped field values. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to be processed. * @param \Drupal\views\ResultRow $row * The result row object containing the values. * * @return bool|\Drupal\Core\Entity\FieldableEntityInterface * Returns a new entity object containing the grouped field values. */
$this->entityTypeManager->expects($this->any())
      ->method('getDefinition')
      ->willReturn($entity_type);
  }

}

class FieldTestEntityField extends EntityField {

  public function executePrepareItemsByDelta(array $all_values) {
    return $this->prepareItemsByDelta($all_values);
  }

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