You are here

protected function PreprocessBase::preprocessDescription in Express 8

Converts any set description variable into a traversable array.

See also

https://www.drupal.org/node/2324025

2 calls to PreprocessBase::preprocessDescription()
BootstrapModal::preprocessVariables in themes/contrib/bootstrap/src/Plugin/Preprocess/BootstrapModal.php
Preprocess the variables array.
BootstrapPanel::preprocessVariables in themes/contrib/bootstrap/src/Plugin/Preprocess/BootstrapPanel.php
Preprocess the variables array.

File

themes/contrib/bootstrap/src/Plugin/Preprocess/PreprocessBase.php, line 76
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

protected function preprocessDescription() {
  if ($this->variables
    ->offsetGet('description')) {

    // Retrieve the description attributes.
    $description_attributes = $this->variables
      ->offsetGet('description_attributes', []);

    // Remove standalone description attributes.
    $this->variables
      ->offsetUnset('description_attributes');

    // Build the description attributes.
    if ($id = $this->variables
      ->getAttribute('id')) {
      $this->variables
        ->setAttribute('aria-describedby', "{$id}--description");
      $description_attributes['id'] = "{$id}--description";
    }

    // Replace the description variable.
    $this->variables
      ->offsetSet('description', [
      'attributes' => new Attribute($description_attributes),
      'content' => $this->variables['description'],
      'position' => $this->variables
        ->offsetGet('description_display', 'after'),
    ]);
  }
}