function DisplayPluginBase::optionLink

Same name in other branches
  1. 8.9.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. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::optionLink()

Overrides DisplayPluginInterface::optionLink

1 call to DisplayPluginBase::optionLink()
DisplayPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Provide a form to edit options for this plugin.

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.