public function Redirect404Operations::render in Redirect 8
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides FieldPluginBase::render
File
- modules/
redirect_404/ src/ Plugin/ views/ field/ Redirect404Operations.php, line 83
Class
- Redirect404Operations
- Provides a views field for the redirect operation buttons.
Namespace
Drupal\redirect_404\Plugin\views\fieldCode
public function render(ResultRow $values) {
$links = [];
$query = [
'query' => [
'source' => ltrim($this
->getValue($values, 'path'), '/'),
'language' => $this
->getValue($values, 'langcode'),
'destination' => $this->view
->getPath(),
],
];
$links['add'] = [
'title' => $this
->t('Add redirect'),
'url' => Url::fromRoute('redirect.add', [], $query),
];
if ($this->currentUser
->hasPermission('administer redirect settings')) {
$links['ignore'] = [
'title' => $this
->t('Ignore'),
'url' => Url::fromRoute('redirect_404.ignore_404', [
'path' => $this
->getValue($values, 'path'),
'langcode' => $this
->getValue($values, 'langcode'),
]),
];
}
$operations['data'] = [
'#type' => 'operations',
'#links' => $links,
];
return $this->renderer
->render($operations);
}