protected function Links::getLinks in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/src/Plugin/views/field/Links.php \Drupal\views\Plugin\views\field\Links::getLinks()
- 10 core/modules/views/src/Plugin/views/field/Links.php \Drupal\views\Plugin\views\field\Links::getLinks()
Gets the list of links used by this field.
Return value
array The links which are used by the render function.
1 call to Links::getLinks()
- Dropbutton::render in core/
modules/ views/ src/ Plugin/ views/ field/ Dropbutton.php - Renders the field.
File
- core/
modules/ views/ src/ Plugin/ views/ field/ Links.php, line 63
Class
- Links
- A abstract handler which provides a collection of links.
Namespace
Drupal\views\Plugin\views\fieldCode
protected function getLinks() {
$links = [];
foreach ($this->options['fields'] as $field) {
if (empty($this->view->field[$field]->last_render_text)) {
continue;
}
$title = $this->view->field[$field]->last_render_text;
$path = '';
$url = NULL;
if (!empty($this->view->field[$field]->options['alter']['path'])) {
$path = $this->view->field[$field]->options['alter']['path'];
}
elseif (!empty($this->view->field[$field]->options['alter']['url']) && $this->view->field[$field]->options['alter']['url'] instanceof UrlObject) {
$url = $this->view->field[$field]->options['alter']['url'];
}
// Make sure that tokens are replaced for this paths as well.
$tokens = $this
->getRenderTokens([]);
$path = strip_tags(Html::decodeEntities($this
->viewsTokenReplace($path, $tokens)));
$links[$field] = [
'url' => $path ? UrlObject::fromUri('internal:/' . $path) : $url,
'title' => $title,
];
if (!empty($this->options['destination'])) {
$links[$field]['query'] = \Drupal::destination()
->getAsArray();
}
}
return $links;
}