You are here

public function ThemeSuggestions::alter in Express 8

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 AlterInterface::alter

File

themes/contrib/bootstrap/src/Plugin/Alter/ThemeSuggestions.php, line 82
Contains \Drupal\bootstrap\Plugin\Alter\ThemeSuggestions.

Class

ThemeSuggestions
Implements hook_theme_suggestions_alter().

Namespace

Drupal\bootstrap\Plugin\Alter

Code

public function alter(&$suggestions, &$variables = [], &$hook = NULL) {

  // This is intentionally backwards. The "original" theme hook is actually
  // the hook being invoked. The provided $hook (to the alter) is the watered
  // down version of said original hook.
  $this->hook = !empty($variables['theme_hook_original']) ? $variables['theme_hook_original'] : $hook;
  $this->hookSuggestions = explode('__', $this->hook);
  $this->originalHook = $hook;
  $this->suggestions = $suggestions;
  $this->variables = Variables::create($variables);
  $this->element = $this->variables->element;

  // Processes the necessary theme hook suggestions.
  $this
    ->processSuggestions();

  // Ensure the list of suggestions is unique.
  $suggestions = array_unique($this->suggestions);
}