You are here

public function StylePluginBase::addClassesToBuild in Bootstrap Styles 1.0.x

Helper function to add the classes to the build.

Parameters

array $build: The build array.

array $classes: Array of the classes that we need to assign to build.

string $theme_wrapper: The theme wrapper if exists.

Return value

array The build array.

6 calls to StylePluginBase::addClassesToBuild()
BackgroundColor::build in src/Plugin/BootstrapStyles/Style/BackgroundColor.php
Border::build in src/Plugin/BootstrapStyles/Style/Border.php
BoxShadow::build in src/Plugin/BootstrapStyles/Style/BoxShadow.php
Margin::build in src/Plugin/BootstrapStyles/Style/Margin.php
TextAlignment::build in src/Plugin/BootstrapStyles/Style/TextAlignment.php

... See full list

File

src/Style/StylePluginBase.php, line 197

Class

StylePluginBase
A base class to help developers implement their own Styles Group plugins.

Namespace

Drupal\bootstrap_styles\Style

Code

public function addClassesToBuild(array $build, array $classes, $theme_wrapper = NULL) {

  // Assign the style to element or its theme wrapper if exist.
  if ($theme_wrapper && isset($build['#theme_wrappers'][$theme_wrapper])) {
    $build['#theme_wrappers'][$theme_wrapper]['#attributes']['class'] = array_merge($build['#theme_wrappers'][$theme_wrapper]['#attributes']['class'], $classes);
  }
  elseif (isset($build['#attributes']['class'])) {
    $build['#attributes']['class'] = array_merge($build['#attributes']['class'], $classes);
  }
  else {
    $build['#attributes']['class'] = $classes;
  }
  return $build;
}