More tidying.
[yaffs-website] / web / modules / contrib / views_bootstrap / src / Plugin / views / style / ViewsBootstrapTable.php
1 <?php
2
3 namespace Drupal\views_bootstrap\Plugin\views\style;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\style\Table;
7
8 /**
9  * Style plugin to render each item as a row in a Bootstrap table.
10  *
11  * @ingroup views_style_plugins
12  *
13  * @ViewsStyle(
14  *   id = "views_bootstrap_table",
15  *   title = @Translation("Bootstrap Table"),
16  *   help = @Translation("Displays rows in a Bootstrap table."),
17  *   theme = "views_bootstrap_table",
18  *   theme_file = "../views_bootstrap.theme.inc",
19  *   display_types = {"normal"}
20  * )
21  */
22 class ViewsBootstrapTable extends Table {
23
24   /**
25    * Definition.
26    */
27   protected function defineOptions() {
28     $options = parent::defineOptions();
29     $options['bootstrap_styles'] = ['default' => []];
30     $options['responsive'] = ['default' => FALSE];
31
32     return $options;
33   }
34
35   /**
36    * Render the given style.
37    */
38   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
39     parent::buildOptionsForm($form, $form_state);
40
41     $form['responsive'] = [
42       '#type' => 'checkbox',
43       '#title' => $this->t('Responsive'),
44       '#default_value' => $this->options['responsive'],
45       '#description' => $this->t('To make a table scroll horizontally on small devices.'),
46     ];
47
48     $form['bootstrap_styles'] = [
49       '#title' => $this->t('Bootstrap styles'),
50       '#type' => 'checkboxes',
51       '#default_value' => $this->options['bootstrap_styles'],
52       '#options' => [
53         'striped' => $this->t('Striped'),
54         'bordered' => $this->t('Bordered'),
55         'hover' => $this->t('Hover'),
56         'condensed' => $this->t('Condensed'),
57       ],
58     ];
59   }
60
61 }