function Attachment::optionsSummary

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

Provide the summary for attachment options in the views UI.

This output is returned as an array.

Overrides DisplayPluginBase::optionsSummary

File

core/modules/views/src/Plugin/views/display/Attachment.php, line 70

Class

Attachment
The plugin that handles an attachment display.

Namespace

Drupal\views\Plugin\views\display

Code

public function optionsSummary(&$categories, &$options) {
    // It is very important to call the parent function here:
    parent::optionsSummary($categories, $options);
    $categories['attachment'] = [
        'title' => $this->t('Attachment settings'),
        'column' => 'second',
        'build' => [
            '#weight' => -10,
        ],
    ];
    $displays = array_filter($this->getOption('displays'));
    if (count($displays) > 1) {
        $attach_to = $this->t('Multiple displays');
    }
    elseif (count($displays) == 1) {
        $display = array_shift($displays);
        if ($display = $this->view->storage
            ->getDisplay($display)) {
            $attach_to = $display['display_title'];
        }
    }
    if (!isset($attach_to)) {
        $attach_to = $this->t('Not defined');
    }
    $options['displays'] = [
        'category' => 'attachment',
        'title' => $this->t('Attach to'),
        'value' => $attach_to,
    ];
    $options['attachment_position'] = [
        'category' => 'attachment',
        'title' => $this->t('Attachment position'),
        'value' => $this->attachmentPositions($this->getOption('attachment_position')),
    ];
    $options['inherit_arguments'] = [
        'category' => 'attachment',
        'title' => $this->t('Inherit contextual filters'),
        'value' => $this->getOption('inherit_arguments') ? $this->t('Yes') : $this->t('No'),
    ];
    $options['inherit_exposed_filters'] = [
        'category' => 'attachment',
        'title' => $this->t('Inherit exposed filters'),
        'value' => $this->getOption('inherit_exposed_filters') ? $this->t('Yes') : $this->t('No'),
    ];
    $options['inherit_pager'] = [
        'category' => 'pager',
        'title' => $this->t('Inherit pager'),
        'value' => $this->getOption('inherit_pager') ? $this->t('Yes') : $this->t('No'),
    ];
    $options['render_pager'] = [
        'category' => 'pager',
        'title' => $this->t('Render pager'),
        'value' => $this->getOption('render_pager') ? $this->t('Yes') : $this->t('No'),
    ];
}

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