You are here

public function DefaultRevisionedDisplay::optionLink in Config Entity Revisions 8.2

Returns a link to a section of a form.

Because forms may be split up into sections, this provides an easy URL to exactly the right section. Don't override this.

Overrides DisplayPluginBase::optionLink

File

modules/view_revisions/src/Plugin/views/display/DefaultRevisionedDisplay.php, line 15

Class

DefaultRevisionedDisplay
Class DefaultRevisionedDisplay

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 \Drupal::l($text, new Url('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),
    ],
  ]));
}