Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Preprocess / ProgressBar.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Preprocess\ProgressBar.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Preprocess;
8
9 use Drupal\bootstrap\Annotation\BootstrapPreprocess;
10 use Drupal\bootstrap\Utility\Variables;
11 use Drupal\Component\Utility\Html;
12
13 /**
14  * Pre-processes variables for the "progress_bar" theme hook.
15  *
16  * @ingroup plugins_preprocess
17  *
18  * @BootstrapPreprocess("progress_bar")
19  */
20 class ProgressBar extends PreprocessBase implements PreprocessInterface {
21
22   /**
23    * {@inheritdoc}
24    */
25   public function preprocessVariables(Variables $variables) {
26     // Ensure a unique ID, generating one if needed.
27     $id = $variables->getAttribute('id', Html::getUniqueId($variables->offsetGet('id', 'progress-bar')));
28     $variables->setAttribute('id', $id);
29     unset($variables['id']);
30
31     // Preprocess attributes.
32     $this->preprocessAttributes();
33   }
34
35 }