You are here

public function PreprocessBase::preprocess in Express 8

Preprocess theme hook variables.

Parameters

array $variables: The variables array, passed by reference (modify in place).

string $hook: The name of the theme hook.

array $info: The theme hook info array.

Overrides PreprocessInterface::preprocess

File

themes/contrib/bootstrap/src/Plugin/Preprocess/PreprocessBase.php, line 45
Contains \Drupal\bootstrap\Plugin\Preprocess\PreprocessBase.

Class

PreprocessBase
Base preprocess class used to build the necessary variables for templates.

Namespace

Drupal\bootstrap\Plugin\Preprocess

Code

public function preprocess(array &$variables, $hook, array $info) {
  $this->hook = $hook;
  $this->info = $info;
  $this->variables = Variables::create($variables);
  if ($this->variables->element) {

    // Check for errors and set the "has_error" property flag.
    if (!$this->variables->element
      ->hasProperty('has_error')) {
      $errors = $this->variables->element
        ->getProperty('errors');
      $this->variables->element
        ->setProperty('has_error', isset($errors) || $this->variables->element
        ->getProperty('required') && $this->theme
        ->getSetting('forms_required_has_error'));
    }
    $this
      ->preprocessElement($this->variables->element, $this->variables);
  }
  $this
    ->preprocessVariables($this->variables);
}