You are here

public function Links::preprocessVariables in Open Social 8.9

Same name and namespace in other branches
  1. 8 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()
  2. 8.2 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()
  3. 8.3 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()
  4. 8.4 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()
  5. 8.5 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()
  6. 8.6 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()
  7. 8.7 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()
  8. 8.8 themes/socialbase/src/Plugin/Preprocess/Links.php \Drupal\socialbase\Plugin\Preprocess\Links::preprocessVariables()

Preprocess the variables array.

Parameters

\Drupal\bootstrap\Utility\Variables $variables: The Variables object.

Overrides PreprocessBase::preprocessVariables

File

themes/socialbase/src/Plugin/Preprocess/Links.php, line 20

Class

Links
Pre-processes variables for the "links" theme hook.

Namespace

Drupal\socialbase\Plugin\Preprocess

Code

public function preprocessVariables(Variables $variables) {
  unset($variables['links']['comment-add']);
  unset($variables['links']['comment-comments']);

  // Move CSS class to "li" tag for marking a no-link item as disabled.
  foreach ($variables['links'] as &$link) {
    if (isset($link['text_attributes'])) {

      /** @var \Drupal\Core\Template\Attribute $text_attributes */
      $text_attributes = $link['text_attributes'];
      if ($link['disabled'] = $text_attributes
        ->hasClass('disabled')) {

        /** @var \Drupal\Core\Template\Attribute $attributes */
        $attributes = $link['attributes'];
        $attributes
          ->addClass('disabled');
        $text_attributes
          ->removeClass('disabled');
      }
    }
  }
}