You are here

public function BootstrapLayout::getStyleOptions in Bootstrap Layout Builder 2.x

Same name and namespace in other branches
  1. 1.x src/Plugin/Layout/BootstrapLayout.php \Drupal\bootstrap_layout_builder\Plugin\Layout\BootstrapLayout::getStyleOptions()

Helper function to get the options of given style name.

Parameters

string $name: A config style name like background_color.

Return value

array Array of key => value of style name options.

File

src/Plugin/Layout/BootstrapLayout.php, line 273

Class

BootstrapLayout
A layout from our bootstrap layout builder.

Namespace

Drupal\bootstrap_layout_builder\Plugin\Layout

Code

public function getStyleOptions(string $name) {
  $config = $this->configFactory
    ->get('bootstrap_layout_builder.settings');
  $options = [];
  $config_options = $config
    ->get($name);
  $options = [
    '_none' => $this
      ->t('N/A'),
  ];
  $lines = explode(PHP_EOL, $config_options);
  foreach ($lines as $line) {
    $line = explode('|', $line);
    if ($line && isset($line[0]) && isset($line[1])) {
      $options[$line[0]] = $line[1];
    }
  }
  return $options;
}