You are here

protected function FileDownloadUrl::computeValue in JSON:API 8

Initialize the internal field list with the modified items.

Overrides ComputedItemListTrait::computeValue

File

src/Field/FileDownloadUrl.php, line 55

Class

FileDownloadUrl
Extends core URL field functionality.

Namespace

Drupal\jsonapi\Field

Code

protected function computeValue() {
  $url_list = [];
  foreach ($this
    ->getEntity()
    ->get('uri') as $delta => $uri_item) {
    $path = $this
      ->fileCreateRootRelativeUrl($uri_item->value);
    $url_list[$delta] = $this
      ->createItem($delta, $path);
  }
  $this->list = $url_list;
}