You are here

public function Pdf::optionsSummary in PDF Generator 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views/display/Pdf.php \Drupal\pdf_generator\Plugin\views\display\Pdf::optionsSummary()

Provides the default summary for options in the views UI.

This output is returned as an array.

Overrides PathPluginBase::optionsSummary

File

src/Plugin/views/display/Pdf.php, line 177

Class

Pdf
The plugin that handles a feed, such as RSS or atom.

Namespace

Drupal\pdf_generator\Plugin\views\display

Code

public function optionsSummary(&$categories, &$options) {
  parent::optionsSummary($categories, $options);

  // Since we're childing off the 'path' type, we'll still *call* our
  // category 'page' but let's override it so it says feed settings.
  $categories['page'] = [
    'title' => $this
      ->t('PDF settings'),
    'column' => 'second',
    'build' => [
      '#weight' => -10,
    ],
  ];
  if ($this
    ->getOption('sitename_title')) {
    $options['title']['value'] = $this
      ->t('Using the site name');
  }
  if ($this
    ->getOption('field_title')) {
    $options['title']['value'] = $this
      ->t('Using field value');
  }
  $displays = array_filter($this
    ->getOption('displays'));
  if (count($displays) > 1) {
    $attach_to = $this
      ->t('Multiple displays');
  }
  elseif (count($displays) == 1) {
    $display = array_shift($displays);
    $displays = $this->view->storage
      ->get('display');
    if (!empty($displays[$display])) {
      $attach_to = $displays[$display]['display_title'];
    }
  }
  if (!isset($attach_to)) {
    $attach_to = $this
      ->t('None');
  }
  $options['displays'] = [
    'category' => 'page',
    'title' => $this
      ->t('Attach to'),
    'value' => $attach_to,
  ];
  $options['inline_css'] = [
    'category' => 'page',
    'title' => $this
      ->t('Inline CSS'),
    'value' => !empty($this
      ->getOption('inline_css')) ? $this
      ->t('Yes') : $this
      ->t('No'),
  ];
  $options['file_css'] = [
    'category' => 'page',
    'title' => $this
      ->t('File CSS'),
    'value' => !empty($this
      ->getOption('file_css')) ? $this
      ->getOption('file_css') : $this
      ->t('None'),
  ];
  $dispositions = $this->pdfGenerator
    ->availableDisposition();
  $options['paper_disposition'] = [
    'category' => 'page',
    'title' => $this
      ->t('Disposition'),
    'value' => !empty($this
      ->getOption('paper_disposition')) ? $dispositions[$this
      ->getOption('paper_disposition')] : $this
      ->t('None'),
  ];
  $sizes = $this->pdfGenerator
    ->pageSizes();
  $options['paper_size'] = [
    'category' => 'page',
    'title' => $this
      ->t('Paper size'),
    'value' => !empty($this
      ->getOption('paper_size')) ? $sizes[$this
      ->getOption('paper_size')] : $this
      ->t('None'),
  ];
}