More tidying.
[yaffs-website] / web / modules / contrib / views_bootstrap / src / Plugin / views / style / ViewsBootstrapAccordion.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\StylePluginBase;
7 use Drupal\views_bootstrap\ViewsBootstrap;
8
9 /**
10  * Style plugin to render each item as a row in a Bootstrap Accordion.
11  *
12  * @ingroup views_style_plugins
13  *
14  * @ViewsStyle(
15  *   id = "views_bootstrap_accordion",
16  *   title = @Translation("Bootstrap Accordion"),
17  *   help = @Translation("Displays rows in a Bootstrap Accordion."),
18  *   theme = "views_bootstrap_accordion",
19  *   theme_file = "../views_bootstrap.theme.inc",
20  *   display_types = {"normal"}
21  * )
22  */
23 class ViewsBootstrapAccordion extends StylePluginBase {
24   /**
25    * Does the style plugin for itself support to add fields to it's output.
26    *
27    * @var bool
28    */
29   protected $usesFields = TRUE;
30
31   /**
32    * Does the style plugin allows to use style plugins.
33    *
34    * @var bool
35    */
36   protected $usesRowPlugin = TRUE;
37
38   /**
39    * Definition.
40    */
41   protected function defineOptions() {
42     $options = parent::defineOptions();
43     $options['panel_title_field'] = ['default' => NULL];
44
45     return $options;
46   }
47
48   /**
49    * Render the given style.
50    */
51   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
52     parent::buildOptionsForm($form, $form_state);
53     if (isset($form['grouping'])) {
54       unset($form['grouping']);
55
56       $form['panel_title_field'] = [
57         '#type' => 'select',
58         '#title' => $this->t('Panel title field'),
59         '#options' => $this->displayHandler->getFieldLabels(TRUE),
60         '#required' => TRUE,
61         '#default_value' => $this->options['panel_title_field'],
62         '#description' => $this->t('Select the field that will be used as the accordian panel titles.'),
63       ];
64     }
65   }
66
67 }