class TableSortIndicator

Pre-processes variables for the "tablesort_indicator" theme hook.

Plugin annotation

@BootstrapPreprocess("tablesort_indicator")

Hierarchy

Expanded class hierarchy of TableSortIndicator

Related topics

Namespace

Drupal\bootstrap\Plugin\Preprocess
Source
class TableSortIndicator extends PreprocessBase implements PreprocessInterface {

  /**
   * {@inheritdoc}
   */
  public function preprocessVariables(Variables $variables) {
    if ($variables->style === 'asc') {
      $icon = Element::createStandalone(Bootstrap::glyphicon('chevron-down', ['#markup' => $this->t('(asc)')]))
        ->addClass('icon-after')
        ->setAttributes([
          'data-toggle' => 'tooltip',
          'data-placement' => 'bottom',
          'title' => $this->t('Sort ascending'),
        ]);
    }
    else {
      $icon = Element::createStandalone(Bootstrap::glyphicon('chevron-up', ['#markup' => $this->t('(desc)')]))
        ->addClass('icon-after')
        ->setAttributes([
          'data-toggle' => 'tooltip',
          'data-placement' => 'bottom',
          'title' => $this->t('Sort descending'),
        ]);
    }
    $variables->icon = $icon->getArray();
  }

}

Members

Contains filters are case sensitive
Name Modifiers Type Description
PluginBase::$theme protected property The currently set theme object.
PluginBase::__construct public function
PreprocessBase::$hook protected property The theme hook invoked.
PreprocessBase::$info protected property The theme hook info array from the theme registry.
PreprocessBase::$variables protected property The Variables object.
PreprocessBase::preprocess public function Preprocess theme hook variables. Overrides PreprocessInterface::preprocess
PreprocessBase::preprocessAttributes protected function Ensures all attributes have been converted to an Attribute object.
PreprocessBase::preprocessDescription protected function Converts any set description variable into a traversable array.
PreprocessBase::preprocessElement protected function Preprocess the variables array if an element is present.
TableSortIndicator::preprocessVariables public function Preprocess the variables array. Overrides PreprocessBase::preprocessVariables