You are here

public function BackgroundColor::build in Bootstrap Styles 1.0.x

Overrides StylePluginBase::build

File

src/Plugin/BootstrapStyles/Style/BackgroundColor.php, line 119

Class

BackgroundColor
Class BackgroundColor.

Namespace

Drupal\bootstrap_styles\Plugin\BootstrapStyles\Style

Code

public function build(array $build, array $storage, $theme_wrapper = NULL) {
  $classes = [];

  // Backwards compatibility for layouts created on the 1.x version.
  $background_type = $storage['background']['background_type'] ?? 'color';
  if ($background_type != 'video') {
    $classes[] = $storage['background_color']['class'];

    // Responsive.
    $fields = [
      'background_color',
    ];
    $this
      ->buildBreakpoints($classes, $storage, $fields);

    // Add the classes to the build.
    $build = $this
      ->addClassesToBuild($build, $classes, $theme_wrapper);
  }

  // Attach bs-classes to the build.
  $build['#attached']['library'][] = 'bootstrap_styles/plugin.background_color.build';
  return $build;
}