You are here

public function ThemeSuggestions::alter in Open Social 8.8

Same name in this branch
  1. 8.8 themes/socialblue/src/Plugin/Alter/ThemeSuggestions.php \Drupal\socialblue\Plugin\Alter\ThemeSuggestions::alter()
  2. 8.8 themes/socialbase/src/Plugin/Alter/ThemeSuggestions.php \Drupal\socialbase\Plugin\Alter\ThemeSuggestions::alter()
Same name and namespace in other branches
  1. 8.9 themes/socialblue/src/Plugin/Alter/ThemeSuggestions.php \Drupal\socialblue\Plugin\Alter\ThemeSuggestions::alter()

Alters data for a specific hook_TYPE_alter() implementation.

Parameters

mixed $data: The variable that will be passed to hook_TYPE_alter() implementations to be altered. The type of this variable depends on the value of the $type argument. For example, when altering a 'form', $data will be a structured array. When altering a 'profile', $data will be an object.

mixed $context1: (optional) An additional variable that is passed by reference.

mixed $context2: (optional) An additional variable that is passed by reference. If more context needs to be provided to implementations, then this should be an associative array as described above.

Overrides ThemeSuggestions::alter

File

themes/socialblue/src/Plugin/Alter/ThemeSuggestions.php, line 19

Class

ThemeSuggestions
Implements hook_theme_suggestions_alter().

Namespace

Drupal\socialblue\Plugin\Alter

Code

public function alter(&$suggestions, &$context = NULL, &$hook = NULL) {
  parent::alter($suggestions, $context, $hook);

  // Add new template suggestions to be able to override for different style.
  $style = theme_get_setting('style');
  if (!empty($style)) {
    $variables = $this->variables;
    $style_suggestions = [];
    $style_suggestions[] = $variables['theme_hook_original'] . '__' . $style;
    if (!empty($suggestions)) {
      foreach ($suggestions as $suggestion) {
        $style_suggestions[] = $suggestion;
        $style_suggestions[] = $suggestion . '__' . $style;
      }
    }
    $suggestions = $style_suggestions;
  }
}