ad7026cbd729713ba48ef37a2953b22ca25ae05b
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Preprocess / Region.php
1 <?php
2
3 namespace Drupal\bootstrap\Plugin\Preprocess;
4
5 use Drupal\bootstrap\Bootstrap;
6 use Drupal\bootstrap\Utility\Variables;
7
8 /**
9  * Pre-processes variables for the "region" theme hook.
10  *
11  * @ingroup plugins_preprocess
12  *
13  * @BootstrapPreprocess("region")
14  */
15 class Region extends PreprocessBase implements PreprocessInterface {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function preprocessVariables(Variables $variables) {
21     $region = $variables['elements']['#region'];
22     $variables['region'] = $region;
23     $variables['content'] = $variables['elements']['#children'];
24
25     // Help region.
26     if ($region === 'help' && !empty($variables['content'])) {
27       $variables['content'] = [
28         'icon' => Bootstrap::glyphicon('question-sign'),
29         'content' => ['#markup' => $variables['content']],
30       ];
31       $variables->addClass(['alert', 'alert-info', 'messages', 'info']);
32     }
33
34     // Support for "well" classes in regions.
35     static $region_wells;
36     if (!isset($region_wells)) {
37       $region_wells = $this->theme->getSetting('region_wells');
38     }
39     if (!empty($region_wells[$region])) {
40       $variables->addClass($region_wells[$region]);
41     }
42   }
43
44 }