Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Preprocess / Table.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Preprocess\Table.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Preprocess;
8
9 use Drupal\bootstrap\Annotation\BootstrapPreprocess;
10 use Drupal\bootstrap\Utility\Variables;
11
12 /**
13  * Pre-processes variables for the "table" theme hook.
14  *
15  * @ingroup plugins_preprocess
16  *
17  * @BootstrapPreprocess("table")
18  */
19 class Table extends PreprocessBase {
20
21   /**
22    * {@inheritdoc}
23    */
24   public function preprocessVariables(Variables $variables) {
25     // Bordered.
26     $variables['bordered'] = !!$variables->getContext('bordered', $this->theme->getSetting('table_bordered'));
27
28     // Condensed.
29     $variables['condensed'] = !!$variables->getContext('condensed', $this->theme->getSetting('table_condensed'));
30
31     // Hover.
32     $variables['hover'] = !!$variables->getContext('hover', $this->theme->getSetting('table_hover'));
33
34     // Striped.
35     $variables['striped'] = empty($variables['no_striping']) && $variables->getContext('striped', $this->theme->getSetting('table_striped'));
36     unset($variables['no_striping']);
37
38     // Responsive.
39     $responsive = $variables->getContext('responsive', $this->theme->getSetting('table_responsive'));
40     $variables['responsive'] = $responsive == -1 ? !\Drupal::service('router.admin_context')->isAdminRoute() : !!(int) $responsive;
41   }
42
43 }