file TableSortIndicator.php

Namespace

Drupal\bootstrap\Plugin\Preprocess
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Preprocess;
  3. use Drupal\bootstrap\Bootstrap;
  4. use Drupal\bootstrap\Utility\Element;
  5. use Drupal\bootstrap\Utility\Variables;
  6. /**
  7. * Pre-processes variables for the "tablesort_indicator" theme hook.
  8. *
  9. * @ingroup plugins_preprocess
  10. *
  11. * @BootstrapPreprocess("tablesort_indicator")
  12. */
  13. class TableSortIndicator extends PreprocessBase implements PreprocessInterface {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function preprocessVariables(Variables $variables) {
  18. if ($variables->style === 'asc') {
  19. $icon = Element::createStandalone(Bootstrap::glyphicon('chevron-down', ['#markup' => $this->t('(asc)')]))
  20. ->addClass('icon-after')
  21. ->setAttributes([
  22. 'data-toggle' => 'tooltip',
  23. 'data-placement' => 'bottom',
  24. 'title' => $this->t('Sort ascending'),
  25. ]);
  26. }
  27. else {
  28. $icon = Element::createStandalone(Bootstrap::glyphicon('chevron-up', ['#markup' => $this->t('(desc)')]))
  29. ->addClass('icon-after')
  30. ->setAttributes([
  31. 'data-toggle' => 'tooltip',
  32. 'data-placement' => 'bottom',
  33. 'title' => $this->t('Sort descending'),
  34. ]);
  35. }
  36. $variables->icon = $icon->getArray();
  37. }
  38. }

Classes

Name Description
TableSortIndicator Pre-processes variables for the "tablesort_indicator" theme hook.