function DisplayPluginBase::optionLink

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::optionLink()
  2. 10 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::optionLink()
  3. 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::optionLink()

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 1017

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function optionLink($text, $section, $class = '', $title = '') {
  if (!trim($text)) {
    $text = $this->t('Broken field');
  }
  if (!empty($class)) {
    $text = new FormattableMarkup('<span>@text</span>', [
      '@text' => $text,
    ]);
  }
  if (empty($title)) {
    $title = $text;
  }
  return Link::fromTextAndUrl($text, Url::fromRoute('views_ui.form_display', [
    'js' => 'nojs',
    'view' => $this->view->storage
      ->id(),
    'display_id' => $this->display['id'],
    'type' => $section,
  ], [
    'attributes' => [
      'class' => [
        'views-ajax-link',
        $class,
      ],
      'title' => $title,
      'id' => Html::getUniqueId('views-' . $this->display['id'] . '-' . $section),
    ],
  ]))
    ->toString();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.