You are here

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

Overrides StylePluginBase::build

File

src/Plugin/BootstrapStyles/Style/Margin.php, line 206

Class

Margin
Class Margin.

Namespace

Drupal\bootstrap_styles\Plugin\BootstrapStyles\Style

Code

public function build(array $build, array $storage, $theme_wrapper = NULL) {
  $classes = [];
  $directions = [
    'left',
    'top',
    'right',
    'bottom',
  ];
  if (isset($storage['margin']['class'])) {
    $classes[] = $storage['margin']['class'];
  }
  for ($i = 0; $i < 4; $i++) {
    if (isset($storage['margin_' . $directions[$i]]['class'])) {
      $classes[] = $storage['margin_' . $directions[$i]]['class'];
    }
  }

  // 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.margin.build';
  return $build;
}