function UrlPlainFormatter::viewElements
Same name in other branches
- 9 core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\UrlPlainFormatter::viewElements()
- 10 core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\UrlPlainFormatter::viewElements()
- 11.x core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\UrlPlainFormatter::viewElements()
Overrides FormatterInterface::viewElements
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ UrlPlainFormatter.php, line 24
Class
- UrlPlainFormatter
- Plugin implementation of the 'file_url_plain' formatter.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
assert($file instanceof FileInterface);
$elements[$delta] = [
'#markup' => $file->createFileUrl(),
'#cache' => [
'tags' => $file->getCacheTags(),
],
];
}
return $elements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.